:root {
  --bg: #fafafa;
  --text: #222;
  --text-muted: #666;
  --text-hover: #555;
  --border: #ddd;
  --border-light: #eee;
  --tag-bg: #eee;
  --tag-text: #555;
  --btn-bg: #fff;
  --btn-active-bg: #222;
  --btn-active-text: #fff;
  --code-bg: #f4f4f4;
  --focus-bg: #f0f0f0;
  --link: #0066cc;
  --link-hover: #004499;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --text-muted: #999;
    --text-hover: #bbb;
    --border: #333;
    --border-light: #2a2a2a;
    --tag-bg: #333;
    --tag-text: #aaa;
    --btn-bg: #252525;
    --btn-active-bg: #e0e0e0;
    --btn-active-text: #1a1a1a;
    --code-bg: #252525;
    --focus-bg: #252525;
    --link: #6ab0f3;
    --link-hover: #8fc4f7;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1rem;
  color: var(--text);
  background: var(--bg);
}

nav {
  margin-bottom: 2rem;
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
}

nav a:hover {
  color: var(--text);
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.5rem;
}

article header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.tags {
  margin-top: 0.5rem;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  margin-right: 0.25rem;
  color: var(--tag-text);
}

.search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--btn-bg);
  color: var(--text);
  font-size: 1rem;
}

.search:focus {
  outline: none;
  border-color: var(--text-muted);
}

.search::placeholder {
  color: var(--text-muted);
}

.filters {
  margin-bottom: 1.5rem;
}

.category-filter {
  background: var(--btn-bg);
  border: 1px solid var(--border);
  padding: 0.25rem 0.75rem;
  border-radius: 3px;
  font-size: 0.875rem;
  cursor: pointer;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.category-filter:hover {
  background: var(--focus-bg);
}

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

.category-filter.off {
  text-decoration: line-through;
  opacity: 0.5;
}

.post-preview {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.post-preview header {
  margin-bottom: 1rem;
}

.post-preview a {
  text-decoration: none;
  color: inherit;
}

.post-preview a:hover h2 {
  color: var(--text-hover);
}

.post-preview.hidden {
  display: none;
}

.content h1 { font-size: 1.5rem; }
.content h2 { font-size: 1.25rem; }
.content h3 { font-size: 1.1rem; }

.content a {
  color: var(--link);
  text-decoration: underline;
}

.content a:hover {
  color: var(--link-hover);
}

.content p {
  margin: 1rem 0;
}

.content blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding-left: 1rem;
  color: var(--text-muted);
}

.content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
}

.content a:has(img) {
  display: block;
}

.content pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
  font-size: 0.875rem;
}

.content code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.9em;
}

.content p code {
  background: var(--code-bg);
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  max-width: 320px;
}

.modal-content h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.modal-content dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
}

.modal-content dt {
  text-align: right;
}

.modal-content dd {
  color: var(--text-muted);
}

kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-family: inherit;
  font-size: 0.875rem;
}
