:root {
  --bg: #070b14;
  --surface: #0e1420;
  --surface-2: #151d2e;
  --ink: #e8edf5;
  --muted: #8e9ab0;
  --line: #1e2840;
  --accent: #f2b23e;
  --accent-ink: #1a1304;
  --accent-soft: rgba(242, 178, 62, .14);
  --font: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --max: 920px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 20, .85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  font-weight: 700; font-size: 20px;
  display: inline-flex; align-items: center; gap: 10px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: block;
  box-shadow: 0 0 0 2px var(--line);
}
.social { display: flex; gap: 6px; }
.social a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: color .15s ease, background-color .15s ease;
}
.social a:hover { color: var(--ink); background: var(--surface-2); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
.social span { display: none; }
@media (min-width: 600px) { .social span { display: inline; } }

/* ---------- intro ---------- */
.intro { padding: 56px 0 8px; }
.intro h1 { margin: 0 0 8px; font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }
.intro p { margin: 0; color: var(--muted); max-width: 40em; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-btn {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.tag-btn:hover { border-color: var(--muted); color: var(--ink); }
.tag-btn[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.sort { display: flex; align-items: center; gap: 10px; flex: none; }
.sort label { font-size: 14px; color: var(--muted); }
.sort select {
  font: inherit; font-size: 14px;
  padding: 7px 32px 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e9ab0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.sort select:hover { border-color: var(--muted); }

.result-count { padding: 14px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- posts ---------- */
.posts { list-style: none; margin: 0; padding: 0 0 48px; }
.post {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px;
  padding: 28px 0; border-bottom: 1px solid var(--line);
}
.thumb {
  display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .3s ease;
}
.post:hover .thumb img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) { .thumb img { transition: none; } .post:hover .thumb img { transform: none; } }
.post-meta { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.post[hidden] { display: none; }
.post time { font-variant-numeric: tabular-nums; }
.post h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.45; font-weight: 700; }
.post h2 a:hover { color: var(--accent); }
.post p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.post-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.post-tags button {
  font: inherit; font-size: 13px; line-height: 1.5; cursor: pointer;
  padding: 1px 10px; border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--muted);
}
.post-tags button:hover { color: var(--ink); }
.post-tags button.active { background: var(--accent-soft); color: var(--accent); }

.empty {
  padding: 48px 0; text-align: center; color: var(--muted);
}
.empty button {
  font: inherit; color: var(--accent); background: none; border: 0;
  cursor: pointer; text-decoration: underline; padding: 0;
}

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

@media (max-width: 640px) {
  .intro { padding-top: 40px; }
  .toolbar { flex-direction: column; gap: 16px; }
  .sort { align-self: flex-end; }
  .post { grid-template-columns: 1fr; gap: 14px; }
}

/* ---------- article page ---------- */
.article { padding: 48px 0 64px; }
.article-head { margin-bottom: 28px; }
.article-head h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 38px); line-height: 1.25; letter-spacing: -0.01em; }
.article-head .post-meta { margin-bottom: 14px; }
.article-head .post-tags a {
  font-size: 13px; line-height: 1.5; padding: 1px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.article-head .post-tags a:hover { color: var(--ink); }
.article-hero { aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin: 0 0 36px; }
.article-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prose { font-size: 17px; line-height: 1.75; max-width: 70ch; }
.prose h2 { font-size: 24px; margin: 2.2em 0 .6em; line-height: 1.3; }
.prose h3 { font-size: 19px; margin: 1.8em 0 .5em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.2em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .9em; background: var(--surface-2); padding: .15em .4em; border-radius: 4px; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; overflow-x: auto; font-size: 14px; line-height: 1.6; margin: 0 0 1.4em; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose blockquote { margin: 0 0 1.2em; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.4em; font-size: 15px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.back { display: inline-block; margin-top: 40px; color: var(--muted); }
.back:hover { color: var(--ink); }
