/* ---------- Tokens ---------- */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #1d1b18;
  --muted: #6b665d;
  --line: #e7e2d8;
  --accent: #2f7d5b;
  --accent-soft: #e3f1ea;
  --code-bg: #f2efe8;
  --shadow: 0 1px 2px rgba(29, 27, 24, .04), 0 8px 24px rgba(29, 27, 24, .06);
  --radius: 14px;
  --max: 720px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121412;
    --surface: #1a1d1a;
    --text: #ebe8e1;
    --muted: #9c978c;
    --line: #2a2e2a;
    --accent: #8fc9a8;
    --accent-soft: #1f2d25;
    --code-bg: #1f231f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121412;
  --surface: #1a1d1a;
  --text: #ebe8e1;
  --muted: #9c978c;
  --line: #2a2e2a;
  --accent: #8fc9a8;
  --accent-soft: #1f2d25;
  --code-bg: #1f231f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { font-family: var(--font-serif); font-weight: 600; font-size: 20px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; margin-left: 6px;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
[data-theme-resolved="dark"] .theme-toggle .sun { display: block; }
[data-theme-resolved="dark"] .theme-toggle .moon { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 40px; }
.avatar {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-serif); font-weight: 600; font-size: 28px;
  border: 1px solid var(--line); margin-bottom: 24px;
}
.eyebrow { color: var(--accent); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 8px; }
.hero h1 {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(36px, 7vw, 56px); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 20px;
}
.lede { font-size: 19px; color: var(--muted); margin: 0 0 28px; max-width: 34em; }
.socials { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 0; list-style: none; }
.socials a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 15px;
  transition: border-color .15s, transform .15s;
}
.socials a:hover { border-color: var(--accent); transform: translateY(-1px); }
.socials svg { width: 16px; height: 16px; flex: none; }

/* ---------- Sections ---------- */
section { padding: 40px 0; }
.section-title {
  font-family: var(--font-serif); font-weight: 600; font-size: 26px; letter-spacing: -.01em;
  margin: 0 0 20px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.section-title small { font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--muted); }
.prose p { margin: 0 0 1em; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.card .icon { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.card .icon svg { width: 18px; height: 18px; }

/* ---------- Post list ---------- */
.post-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.post-item a {
  display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: inherit; text-decoration: none;
  transition: box-shadow .2s, border-color .2s, transform .2s;
}
.post-item a:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); transform: translateY(-2px); }
.post-item img { width: 120px; height: 80px; object-fit: cover; border-radius: 10px; background: var(--code-bg); }
.post-item img.contain { object-fit: contain; background: #fff; }
.post-item h3 { margin: 0 0 4px; font-size: 18px; line-height: 1.35; }
.post-item p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.tag { color: var(--accent); }

/* ---------- Article ---------- */
.article-head { padding: 56px 0 24px; }
.article-head h1 { font-family: var(--font-serif); font-weight: 600; font-size: clamp(32px, 6vw, 46px); line-height: 1.12; letter-spacing: -.02em; margin: 8px 0 12px; }
.article-cover { border-radius: var(--radius); border: 1px solid var(--line); margin: 8px 0 32px; aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.article h2 { font-family: var(--font-serif); font-weight: 600; font-size: 26px; margin: 2em 0 .6em; letter-spacing: -.01em; }
.article ol, .article ul { padding-left: 1.3em; }
.article li { margin: 0 0 1em; }
.article code { font-family: var(--font-mono); font-size: .86em; background: var(--code-bg); padding: .15em .4em; border-radius: 6px; }
.article pre {
  font-family: var(--font-mono); font-size: 14px; line-height: 1.6;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; margin: .6em 0 0;
}
.article pre code { background: none; padding: 0; font-size: inherit; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 1.5em 0; }
.callout p:last-child { margin: 0; }
.post-nav { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); margin-top: 48px; padding-top: 24px; font-size: 15px; }
.post-nav a { text-decoration: none; }
.post-nav span { display: block; color: var(--muted); font-size: 13px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 28px 0 40px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .hero { padding-top: 48px; }
  .nav a.hide-sm { display: none; }
  .post-item a { grid-template-columns: 1fr; }
  .post-item img { width: 100%; height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---------- Drafts ---------- */
.draft-banner { background: #fff4d6; color: #5c4400; border: 1px solid #f0d98a; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 24px; }
.todo { background: #fff4d6; color: #5c4400; padding: .1em .35em; border-radius: 4px; font-size: .92em; }
[data-theme-resolved="dark"] .draft-banner, [data-theme-resolved="dark"] .todo { background: #3a2f10; color: #f3dc94; border-color: #5a4a1a; }
.article table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 1em 0 1.5em; display: block; overflow-x: auto; }
.article th, .article td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.article th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.article h3 { font-size: 19px; margin: 1.6em 0 .4em; }
