:root {
  --surface: #f8f9ff;
  --card: #ffffff;
  --text: #0b1c30;
  --muted: #434655;
  --line: #c3c6d7;
  --primary: #004ac6;
  --primary-hover: #003ea8;
  --primary-soft: #dbe1ff;
  --code-bg: #213145;
  --code-text: #eaf1ff;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 400 16px/1.65 "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
img { max-width: 100%; height: auto; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(248, 249, 255, 0.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(195, 198, 215, 0.5);
  padding-top: env(safe-area-inset-top, 0px);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 18px; letter-spacing: -0.015em; }
.brand .muted { color: var(--muted); font-weight: 400; }
.logo { width: 32px; height: 32px; display: block; flex: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; padding: 10px 12px; border-radius: 8px; }
.nav a:hover { color: var(--text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 20px; border-radius: 8px;
  background: var(--primary); color: #fff !important;
  font-weight: 500; font-size: 14px; text-decoration: none; transition: background 0.15s;
}
.btn:hover { background: var(--primary-hover); }
.nav .btn { min-height: 40px; padding: 0 16px; }
@media (max-width: 640px) { .nav .hide-sm { display: none; } }

/* index */
.hero { padding: 56px 0 24px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(30px, 5vw, 44px); line-height: 1.12; letter-spacing: -0.03em; font-weight: 600; max-width: 20ch; }
.lead { margin: 14px 0 0; max-width: 56ch; color: var(--muted); font-size: 18px; }

.list { padding-bottom: 64px; }
.tools { display: none; flex-wrap: wrap; align-items: center; gap: 12px; margin: 24px 0; }
html.js .tools { display: flex; }
.search {
  flex: 1 1 220px; max-width: 320px; height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  font: inherit; font-size: 15px; color: var(--text);
}
.search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.15); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-btn {
  height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted); font: 500 14px/1 inherit; font-family: inherit; cursor: pointer;
}
.tag-btn:hover { color: var(--text); }
.tag-btn.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-top: 8px; }
.card { background: var(--card); border: 1px solid rgba(195, 198, 215, 0.6); border-radius: var(--radius); transition: border-color 0.15s, box-shadow 0.15s; }
.card:hover { border-color: var(--primary); box-shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.18); }
.card-link { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 22px; color: inherit; text-decoration: none; }
.card h2, .card h3 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 600; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card .meta { margin-top: auto; padding-top: 6px; font-size: 13px; }
.tag { align-self: flex-start; display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: #003ea8; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.meta { color: var(--muted); font-size: 14px; }
.empty { padding: 32px 0; text-align: center; color: var(--muted); }

/* post */
.post { padding-top: 40px; padding-bottom: 24px; }
.crumbs { margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); }
.post h1 { margin: 12px 0; font-size: clamp(28px, 4.5vw, 40px); line-height: 1.15; letter-spacing: -0.028em; font-weight: 600; }
.post > .meta { margin: 0 0 28px; }

.prose { font-size: 17px; }
.prose h2 { margin: 2em 0 0.5em; font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; font-weight: 600; }
.prose h3 { margin: 1.6em 0 0.4em; font-size: 19px; font-weight: 600; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose li { margin: 0.3em 0; }
.prose code { font: 500 0.88em "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; background: #e5eeff; padding: 0.12em 0.4em; border-radius: 6px; }
.prose pre {
  position: relative; margin: 0 0 1.4em; padding: 18px; background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius); overflow-x: auto; font-size: 14px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: inherit; font-weight: 400; font-size: inherit; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 10px;
  border: 1px solid rgba(234, 241, 255, 0.25); border-radius: 6px; background: rgba(255, 255, 255, 0.08);
  color: var(--code-text); font: 500 12px/1 "Geist", sans-serif; cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.16); }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 1.2em; font-size: 15px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; background: #eff4ff; }
.prose blockquote { margin: 0 0 1.2em; padding: 4px 0 4px 16px; border-left: 3px solid var(--primary); color: var(--muted); }

.cta {
  margin: 48px 0 0; padding: 28px; border-radius: var(--radius);
  background: var(--card); border: 1px solid rgba(195, 198, 215, 0.6);
}
.cta h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.cta p { margin: 0 0 16px; color: var(--muted); }

.related { padding-top: 24px; padding-bottom: 64px; }
.related h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -0.02em; }

.notfound { padding: 96px 20px; text-align: center; }
.notfound h1 { margin: 0 0 8px; font-size: 32px; }
.notfound p { margin: 0 0 24px; color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid rgba(195, 198, 215, 0.5); padding-bottom: env(safe-area-inset-bottom, 0px); }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 24px; padding-bottom: 24px; color: var(--muted); font-size: 14px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 20px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); }

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