/* ── variables ── */
:root {
  --bg:       #ffffff;
  --text:     #1a1a1a;
  --muted:    #888;
  --border:   #e8e8e8;
  --link:     #2563eb;
  --tag-bg:   #f0f0f0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #141414;
    --text:   #e0e0e0;
    --muted:  #777;
    --border: #2a2a2a;
    --link:   #60a5fa;
    --tag-bg: #252525;
  }
}

[data-theme="dark"] {
  --bg:     #141414;
  --text:   #e0e0e0;
  --muted:  #777;
  --border: #2a2a2a;
  --link:   #60a5fa;
  --tag-bg: #252525;
}

[data-theme="light"] {
  --bg:       #ffffff;
  --text:     #1a1a1a;
  --muted:    #888;
  --border:   #e8e8e8;
  --link:     #2563eb;
  --tag-bg:   #f0f0f0;
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  max-width: 740px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--link); }

/* ── header ── */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.3px;
}

nav { display: flex; gap: 20px; }
nav a {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}
nav a:hover { color: var(--text); }

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  padding: 0;
  margin-left: auto;
  line-height: 1;
  transition: color 0.15s;
}
#theme-toggle:hover { color: var(--text); }

/* ── homepage intro ── */
.intro {
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

/* ── post list ── */
.post-list { list-style: none; }
.post-list li {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.post-list .date {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.post-list a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}
.post-list a:hover { color: var(--link); }

/* ── collapse / show-more ── */
.collapse-hidden { display: none !important; }

.show-more-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 10px;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.show-more-btn:hover { color: var(--text); border-color: var(--text); }

.linked-notes .show-more-btn,
.backlinks .show-more-btn { margin-top: 10px; display: block; }

/* ── single post ── */
article h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: -0.4px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.post-meta .date {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags a {
  background: var(--tag-bg);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.78rem;
}
.tags a:hover { color: var(--text); }

/* ── content typography ── */
.content h2 { font-size: 1.3rem; margin: 2.2rem 0 0.8rem; letter-spacing: -0.2px; }
.content h3 { font-size: 1.1rem; margin: 1.8rem 0 0.6rem; }
.content h4 { font-size: 1rem;   margin: 1.4rem 0 0.5rem; }
.content p  { margin-bottom: 1.1rem; }
.content ul, .content ol { margin: 0.6rem 0 1rem 1.4rem; }
.content li { margin-bottom: 0.3rem; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.content img { max-width: 100%; height: auto; border-radius: 4px; margin: 1rem 0; }
.content a { color: var(--link); }

.content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 18px;
  color: var(--muted);
  margin: 1.2rem 0;
  font-style: italic;
}

/* ── code ── */
code {
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-size: 0.85em;
  background: var(--tag-bg);
  padding: 2px 5px;
  border-radius: 3px;
}

pre {
  background: #1e1e1e !important;
  border-radius: 6px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 1.2rem 0;
  line-height: 1.55;
}
pre code {
  background: none;
  padding: 0;
  font-size: 0.83em;
  color: #d4d4d4;
}

/* ── post nav ── */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}
.post-nav a { color: var(--muted); text-decoration: none; }
.post-nav a:hover { color: var(--text); }

/* ── category filter bar ── */
.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.cat-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 4px 14px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.cat-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.cat-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ── category badge (inline pill) ── */
.cat-badge {
  background: var(--tag-bg);
  border-radius: 4px;
  color: var(--link);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 1px 7px;
  text-decoration: none;
  white-space: nowrap;
}

.cat-badge:hover { text-decoration: underline; }

.post-cats { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }


/* ── tags page ── */
.tag-list { list-style: none; }
.tag-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.tag-list a { text-decoration: none; color: var(--text); font-size: 0.95rem; }
.tag-list .count { color: var(--muted); font-size: 0.82rem; margin-left: 8px; }

/* ── backlinks ── */
.backlinks {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 2px solid var(--link);
}

.backlinks h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--link);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ── inline search ── */
.inline-search {
  width: 100%;
  padding: 7px 14px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 20px;
  outline: none;
  box-sizing: border-box;
}
.inline-search:focus { border-color: var(--link); }
.inline-search::placeholder { color: var(--muted); }

/* ── single post: edited date ── */
.post-meta .date.edited::before { content: "· "; }
.post-meta .date.edited { color: var(--muted); font-style: italic; }

/* ── footer ── */
footer {
  margin-top: 64px;
  padding: 20px 0 40px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
footer a { color: var(--muted); }
