/* ── Variables ───────────────────────────── */

:root {
  --bg: #f7f4ed;
  --paper: #fcfaf6;
  --paper-2: #f0ece3;
  --ink: #2b2520;
  --soft: #7a7267;
  --faint: #b8b0a4;
  --line: #e2dbcf;
  --accent: #8b5e3c;
  --accent-2: #4a7c6f;
  --accent-3: #b4754e;
  --shadow: 0 1px 3px rgba(43, 37, 32, 0.06), 0 8px 40px rgba(43, 37, 32, 0.07);
  --radius: 8px;
  --font-serif: "PingFang SC", "Hiragino Sans GB", "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #1c1a18;
  --paper: #252320;
  --paper-2: #302c28;
  --ink: #e8e2d8;
  --soft: #a0988b;
  --faint: #6b6459;
  --line: #3d3831;
  --accent: #c8946e;
  --accent-2: #7db7a8;
  --accent-3: #d49470;
  --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 8px 40px rgba(0,0,0,0.28);
}

/* ── Reset & Base ────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ───────────────────────────────── */

.shell {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 60px;
}

/* ── Topbar ──────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  backdrop-filter: blur(16px) saturate(0.8);
  -webkit-backdrop-filter: blur(16px) saturate(0.8);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.brand strong {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.brand small {
  color: var(--soft);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.back-link {
  margin-left: auto;
  color: var(--soft);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--ink); }

.theme-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--soft);
  background: var(--paper);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.theme-btn:hover { color: var(--ink); border-color: var(--accent); }
.theme-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

/* ── Article (shared by detail pages) ────── */

.article {
  margin-top: 32px;
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.article-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.article-meta time {
  color: var(--faint);
  font-size: 12px;
}
.article img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0 0 24px;
}
.article h1 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
}
.article h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--accent);
}
.article p {
  margin-bottom: 10px;
  color: var(--soft);
}
.article blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent-2);
  color: var(--soft);
  font-style: italic;
}
.article blockquote p { margin: 4px 0; }
.article hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}
.article pre {
  margin: 10px 0;
  padding: 12px 16px;
  background: var(--paper-2);
  border-radius: 4px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.article pre code {
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--ink);
}
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.article thead th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--line);
  color: var(--accent);
  font-weight: 600;
}
.article tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--soft);
}
.article ul, .article ol {
  margin: 6px 0;
  padding-left: 20px;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.7;
}
.article ul li, .article ol li { margin: 2px 0; }

/* ── Page header (thoughts, uses) ────────── */

.page-header {
  margin-bottom: 44px;
}
.page-header h1 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-2);
}
.page-header p {
  margin-top: 8px;
  color: var(--soft);
  font-size: 15px;
}

/* ── Footer ──────────────────────────────── */

.footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}
.footer a { color: var(--faint); }

/* ── Responsive ──────────────────────────── */

@media (max-width: 640px) {
  .shell { width: min(100% - 22px, 520px); padding-top: 10px; }
  .article { padding: 20px; }
}
