:root {
  --bg: #0d0d0d;
  --bg-surface: #161616;
  --bg-card: #1a1a1a;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #7eb8da;
  --accent-dim: #4a7a96;
  --mark-bg: rgba(126, 184, 218, 0.2);
  --mark-text: #a8d8f0;
  --radius: 8px;
  --max-width: 720px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
}

header nav {
  display: flex;
  gap: 1rem;
}

header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s;
}

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

main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

footer p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.search-box {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-box input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent-dim);
}

.search-box select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s;
}

.result-card:hover {
  border-color: var(--accent-dim);
}

.result-title {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  margin-right: 0.5rem;
}

.result-title:hover {
  text-decoration: underline;
}

.result-snippet {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.result-snippet mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

.pill {
  display: inline-block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15em 0.6em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
  vertical-align: middle;
}

.result-collection {
  vertical-align: baseline;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

.error {
  color: #e07070;
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

.loading {
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

.collections-view h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.collection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-decoration: none;
  transition: border-color 0.15s;
}

.collection-card:hover {
  border-color: var(--accent-dim);
}

.collection-card h3 {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.collection-card .count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.collection-detail h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.entry-detail {
  max-width: var(--max-width);
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.back-link:hover {
  color: var(--accent);
}

.entry-detail h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.entry-meta time {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.entry-content {
  line-height: 1.7;
  font-size: 0.95rem;
}

.entry-content p {
  margin-bottom: 1rem;
}

.entry-source {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.entry-source code {
  background: var(--bg-surface);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.8rem;
}

.btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1.25rem;
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s;
  display: block;
  margin: 1rem auto;
}

.btn:hover {
  border-color: var(--accent-dim);
}

@media (max-width: 480px) {
  header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .search-box {
    flex-direction: column;
  }

  .collection-grid {
    grid-template-columns: 1fr;
  }
}
