:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --paper: #fffcf6;
  --ink: #182018;
  --muted: #596456;
  --line: rgba(24, 32, 24, 0.16);
  --accent: #8b4e34;
  --on-accent: #fffcf6;
  --tag-bg: rgba(139, 78, 52, 0.08);
  --display: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111614;
    --paper: #1a211d;
    --ink: #e8ece5;
    --muted: #abb5a8;
    --line: rgba(232, 236, 229, 0.18);
    --accent: #dca082;
    --on-accent: #111614;
    --tag-bg: rgba(220, 160, 130, 0.12);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f1e8;
  --paper: #fffcf6;
  --ink: #182018;
  --muted: #596456;
  --line: rgba(24, 32, 24, 0.16);
  --accent: #8b4e34;
  --on-accent: #fffcf6;
  --tag-bg: rgba(139, 78, 52, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111614;
  --paper: #1a211d;
  --ink: #e8ece5;
  --muted: #abb5a8;
  --line: rgba(232, 236, 229, 0.18);
  --accent: #dca082;
  --on-accent: #111614;
  --tag-bg: rgba(220, 160, 130, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
::selection { background: var(--accent); color: var(--on-accent); }
.shell { width: min(760px, calc(100% - 40px)); margin-inline: auto; }
.site-home .shell { width: min(860px, calc(100% - 40px)); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: pretty; }
h1 {
  font-family: var(--display);
  font-size: clamp(1.85rem, 4.5vw, 2.8rem);
  line-height: 1.3;
  letter-spacing: -0.025em;
  margin-bottom: 1.25rem;
}
h2 { font-size: 1.4rem; line-height: 1.45; margin-bottom: 0.8rem; }
h3 { font-size: 1.15rem; line-height: 1.5; }
p { margin-bottom: 1.2rem; }
.skip-link {
  position: fixed;
  top: -6rem;
  left: 1rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
}
.skip-link:focus { top: 1rem; color: var(--bg); }
.site-header { padding-block: 20px; }
.nav, .topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav { padding-block: 6px 14px; border-bottom: 1px solid var(--line); }
.brand { font-family: var(--mono); font-size: 0.9rem; font-weight: 700; }
.nav-links, .topbar-links { display: flex; align-items: center; flex-wrap: wrap; gap: 0.9rem; }
.nav-links a, .topbar a { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.9rem; }
.topbar { padding-block: 20px; }
.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--tag-bg); }
.hero { padding-block: 48px 40px; }
.site-home .hero { padding-block: 64px 60px; }
.site-home h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
.name-divider { color: var(--accent); font-weight: 400; }
.eyebrow, .meta, .post-meta {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.7;
  margin-bottom: 0.7rem;
}
.eyebrow { color: var(--accent); letter-spacing: 0.06em; }
.lead { font-size: 1.15rem; margin-bottom: 0.8rem; }
.intro, .section-copy { color: var(--muted); max-width: 660px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1.5rem; margin-top: 1.6rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 0.65rem; min-height: 46px; padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.95rem; font-weight: 600; }
.button-primary { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); }
.button-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.text-link { text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--line); }
.text-link:hover { text-decoration-color: currentColor; }
.section { padding-bottom: 48px; }
.section-head { margin-bottom: 1.4rem; }
.section-head h2 { margin-bottom: 0.35rem; }
.section-head p { margin-bottom: 0; }
.post-list { border-top: 1px solid var(--line); }
.post-card, .post { display: block; padding: 24px 0; border-bottom: 1px solid var(--line); }
.post-card:hover, .post:hover { color: inherit; }
.post-card:hover h3, .post:hover h2 { color: var(--accent); text-decoration: underline; text-underline-offset: 5px; }
.post-card h3, .post h2 { font-size: 1.22rem; line-height: 1.5; margin-bottom: 0.5rem; }
.post-card p:last-child, .post p:last-child { color: var(--muted); margin-bottom: 0; font-size: 0.96rem; }
.archive-link { margin-top: 1.2rem; margin-bottom: 0; }
.about { max-width: 660px; }
.about p { margin-bottom: 0.5rem; }
.contact-section { padding-top: 28px; border-top: 1px solid var(--line); }
.contact-section p { color: var(--muted); margin-bottom: 0.6rem; }
.site-archive .post-list { margin-bottom: 56px; }
.tag { display: inline-block; background: var(--tag-bg); color: var(--accent); padding: 0.2rem 0.6rem; border-radius: 6px; font-size: 0.8rem; }
article { padding-block: 28px 56px; }
article h2 { margin-top: 2.5rem; }
article h3 { margin-top: 1.8rem; }
article a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
article ul, article ol { padding-left: 1.5rem; margin-bottom: 1.4rem; }
article li { margin-bottom: 0.5rem; }
code { font-family: var(--mono); font-size: 0.9em; padding: 0.15em 0.35em; border-radius: 4px; background: var(--tag-bg); }
pre { max-width: 100%; overflow-x: auto; padding: 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; line-height: 1.7; }
pre code { background: none; padding: 0; overflow-wrap: normal; }
blockquote { margin: 1.5rem 0; padding: 0.3rem 1.1rem; border-left: 3px solid var(--accent); color: var(--muted); }
blockquote p:last-child { margin-bottom: 0; }
.table-scroll { max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin-bottom: 1.5rem; }
th, td { text-align: left; padding: 0.65rem; border-bottom: 1px solid var(--line); }
.entry-row { display: flex; justify-content: space-between; gap: 1rem; }
.entry-left { flex: 1; font-weight: 600; }
.entry-right { color: var(--muted); }
.site-footer, footer.shell { padding-block: 12px 32px; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 600px) {
  .shell, .site-home .shell { width: calc(100% - 36px); }
  .site-header { padding-block: 12px; }
  .nav { flex-wrap: wrap; gap: 0.2rem 0.8rem; }
  .nav-links { gap: 0.8rem; }
  .site-home .hero { padding-block: 36px 40px; }
  .hero { padding-block: 32px 28px; }
  .lead { font-size: 1.05rem; }
  .desktop-break { display: none; }
  .post-card, .post { padding-block: 20px; }
  .post-card h3, .post h2 { font-size: 1.12rem; }
  .topbar { align-items: flex-start; gap: 0.5rem; }
  .topbar-links { justify-content: flex-end; gap: 0.8rem; }
  article { padding-top: 20px; }
  .entry-row { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .topbar, .theme-toggle, .skip-link { display: none; }
  body { background: white; color: black; }
  .shell { width: 100%; max-width: none; }
  pre { white-space: pre-wrap; }
}
