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

:root {
  --bg: #ffffff;
  --bg-card: #f8f9fa;
  --text: #212529;
  --text-secondary: #6c757d;
  --border: #dee2e6;
  --accent: #0d6efd;
  --tag-bg: #e9ecef;
  --code-bg: #f1f3f5;
  --code-text: #d63384;
  --blockquote-border: #adb5bd;
  --blockquote-bg: #f8f9fa;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --text: #eaeaea;
  --text-secondary: #a0a0a0;
  --border: #2a2a4a;
  --accent: #4da6ff;
  --tag-bg: #2a2a4a;
  --code-bg: #0f3460;
  --code-text: #e7a8d0;
  --blockquote-border: #4a4a6a;
  --blockquote-bg: #1a1a3e;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition:
    background 0.3s,
    color 0.3s;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#search {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  width: 200px;
  outline: none;
  transition:
    border-color 0.2s,
    width 0.3s;
}

#search:focus {
  border-color: var(--accent);
  width: 280px;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

#theme-toggle:hover {
  border-color: var(--accent);
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.post-card .meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--tag-bg);
  color: var(--text-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.75rem;
}

.post-card .excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hidden {
  display: none;
}

#post-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
}

#post-detail .back-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  padding: 0;
}

#post-detail .back-btn:hover {
  text-decoration: underline;
}

#post-detail h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

#post-detail .meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Markdown body styles */
.markdown-body {
  line-height: 1.8;
}

.markdown-body h1 {
  font-size: 1.75rem;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-size: 1.5rem;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
  font-size: 1.25rem;
  margin: 1.25rem 0 0.5rem;
}

.markdown-body h4 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
}

.markdown-body h5,
.markdown-body h6 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

.markdown-body p {
  margin: 0.75rem 0;
}

.markdown-body strong {
  font-weight: 700;
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
}

.markdown-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.markdown-body pre code {
  background: none;
  color: var(--text);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.markdown-body li {
  margin: 0.25rem 0;
}

.markdown-body blockquote {
  border-left: 4px solid var(--blockquote-border);
  background: var(--blockquote-bg);
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-radius: 0 0.5rem 0.5rem 0;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

.no-results {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 0;
  font-size: 1.1rem;
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  .header-actions {
    width: 100%;
  }

  #search {
    flex: 1;
    width: auto;
  }

  #search:focus {
    width: auto;
  }

  main {
    padding: 1rem;
  }

  #post-detail {
    padding: 1.25rem;
  }

  .markdown-body pre {
    padding: 0.75rem;
    font-size: 0.8rem;
  }
}
