:root {
  --text: #1a1a1a;
  --muted: #666;
  --bg: #fdfdfb;
  --accent: #8b2b2b;
  --border: #e0ddd6;
  --max-width: 42rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", Charter, "Georgia", serif;
  line-height: 1.6;
  font-size: 18px;
}

.site-header, main, .site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-family: -apple-system, "Segoe UI", sans-serif;
}

.site-title { font-weight: 700; text-decoration: none; color: var(--text); }
.site-header nav a { margin-left: 1rem; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.site-header nav a:hover { color: var(--accent); }

main { padding-top: 2rem; padding-bottom: 4rem; min-height: 60vh; }

h1, h2, h3 { font-family: -apple-system, "Segoe UI", sans-serif; line-height: 1.25; }
h1 { font-size: 1.9rem; margin-bottom: 0.25rem; }

a { color: var(--accent); text-decoration-thickness: 1px; }

a.internal-link {
  text-decoration: underline dotted;
  text-decoration-color: var(--accent);
  cursor: help;
}

a.broken-link, span.broken-link {
  color: #a04a4a;
  text-decoration: underline wavy #a04a4a;
  cursor: default;
}

.page-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; font-family: -apple-system, "Segoe UI", sans-serif; }
.page-meta time { margin-right: 0.75rem; }
.tag { margin-right: 0.5rem; color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }

article.page pre { padding: 0.75rem 1rem; overflow-x: auto; background: #f4f2ee; border-radius: 4px; font-size: 0.85rem; }
article.page code { background: #f4f2ee; padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.9em; }
article.page pre code { background: none; padding: 0; }
article.page blockquote { border-left: 3px solid var(--border); margin-left: 0; padding-left: 1rem; color: var(--muted); }
article.page img { max-width: 100%; }

.footnote { font-size: 0.85rem; }

.backlinks { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.backlinks h2 { font-size: 1rem; color: var(--muted); }
.backlinks ul { padding-left: 1.25rem; }

.page-list, .tag-list { list-style: none; padding: 0; }
.page-list li { margin-bottom: 1.25rem; }
.page-list time { color: var(--muted); font-size: 0.8rem; margin-right: 0.5rem; }
.page-list .summary { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.95rem; }
.tag-list li { display: flex; justify-content: space-between; max-width: 20rem; border-bottom: 1px solid var(--border); padding: 0.3rem 0; }
.tag-list .count { color: var(--muted); }

#search-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  margin-bottom: 1.5rem;
}

.popup {
  position: absolute;
  max-width: 22rem;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  z-index: 100;
}
.popup strong { display: block; margin-bottom: 0.35rem; font-family: -apple-system, "Segoe UI", sans-serif; }
.popup p { margin: 0; color: var(--muted); }
.popup[hidden] { display: none; }

.site-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  padding-bottom: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ddd8cf;
    --muted: #999;
    --bg: #17181a;
    --accent: #d98b6b;
    --border: #2c2d30;
  }
  article.page pre, article.page code { background: #212225; }
  .popup { background: #202124; }
}
