:root {
  --bg: #f8f9fa;
  --fg: #212529;
  --accent: #0969da;
  --accent-light: #ddf4ff;
  --border: #d0d7de;
  --code-bg: #f6f8fa;
  --header-bg: #24292f;
  --header-fg: #ffffff;
  --tag-bg: #e1ecf4;
  --tag-fg: #0550ae;
  --category-bg: #dafbe1;
  --category-fg: #116329;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 24px 0;
  margin-bottom: 32px;
}
.site-title a { color: var(--header-fg); text-decoration: none; }
.site-title a:hover { opacity: 0.85; }
.site-description { opacity: 0.8; font-size: 0.95rem; margin-top: 4px; }

/* Post list (index page) */
.post-list { list-style: none; }
.post-list-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.post-list-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.post-list-item h2 { font-size: 1.2rem; margin-bottom: 6px; }
.post-list-item h2 a { color: var(--accent); text-decoration: none; }
.post-list-item h2 a:hover { text-decoration: underline; }
.post-list-meta { font-size: 0.85rem; color: #656d76; }

/* Post page */
.post { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 32px; }
.post-header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.post-title { font-size: 1.6rem; margin-bottom: 12px; }
.post-meta { font-size: 0.9rem; color: #656d76; display: flex; gap: 16px; flex-wrap: wrap; }
.post-tags { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--tag-bg);
  color: var(--tag-fg);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}
.category-tag {
  background: var(--category-bg);
  color: var(--category-fg);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}

/* Post content */
/* Table of Contents */
.post-toc {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}
.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.toc-header:hover { background: var(--accent-light); }
.toc-title { font-weight: 600; font-size: 0.95rem; }
.toc-toggle { font-size: 0.8rem; color: #656d76; transition: transform 0.2s; }
.post-toc.collapsed .toc-toggle { transform: rotate(-90deg); }
.post-toc.collapsed .toc-list { display: none; }
.toc-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  max-height: 60vh;
  overflow-y: auto;
}
.toc-item { margin: 0; }
.toc-item a {
  display: block;
  padding: 5px 16px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.toc-item a:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.toc-item.active a {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
}
.toc-item.toc-h2 a { padding-left: 32px; font-size: 0.85rem; color: #656d76; }
.toc-item.toc-h2.active a { color: var(--accent); }

.post-content h1 { font-size: 1.5rem; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.post-content h2 { font-size: 1.3rem; margin: 24px 0 10px; }
.post-content h3 { font-size: 1.1rem; margin: 20px 0 8px; }
.post-content p { margin: 12px 0; }
.post-content ul, .post-content ol { margin: 12px 0 12px 24px; }
.post-content li { margin: 4px 0; }
.post-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
}
.post-content pre code { background: none; padding: 0; }
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
.post-content th, .post-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.post-content th { background: var(--code-bg); font-weight: 600; }
.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--accent-light);
  border-radius: 0 6px 6px 0;
}
.post-content hr { border: none; border-top: 2px solid var(--border); margin: 32px 0; }

/* Post footer */
.post-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
.post-footer a { color: var(--accent); text-decoration: none; }
.post-footer a:hover { text-decoration: underline; }

/* Navigation */
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.header-brand { flex: 1 1 auto; min-width: 200px; }
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--header-fg);
  font-size: 1.4rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.site-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.site-nav a:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.site-nav a.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-weight: 600;
}

@media (max-width: 768px) {
  .header-inner { position: relative; }
  .nav-toggle { display: block; position: absolute; top: 0; right: 0; }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding-top: 8px;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 10px 12px; }
}

/* Dashboard intro */
.dashboard-intro {
  background: linear-gradient(135deg, var(--accent-light), #f0f6ff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  margin-bottom: 32px;
}
.dashboard-intro h2 { font-size: 1.4rem; margin-bottom: 8px; }
.dashboard-intro p { color: #4a5568; font-size: 0.95rem; }
.dashboard-intro .total-counter {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Category cards */
.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.category-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.category-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.card-icon { font-size: 2rem; margin-bottom: 10px; }
.category-card h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--accent); }
.category-card p { font-size: 0.85rem; color: #656d76; flex: 1; margin-bottom: 12px; }
.card-count {
  font-size: 0.8rem;
  color: var(--tag-fg);
  background: var(--tag-bg);
  padding: 3px 10px;
  border-radius: 12px;
  align-self: flex-start;
}

/* Recent posts section */
.recent-posts { margin-top: 8px; }
.recent-posts h2 { font-size: 1.3rem; margin-bottom: 16px; }

/* Page description */
.page-description {
  color: #656d76;
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* Footer */
.site-footer {
  margin-top: 48px;
  padding: 20px 0;
  text-align: center;
  font-size: 0.85rem;
  color: #656d76;
  border-top: 1px solid var(--border);
}

/* Topic headings for case studies */
.topic-heading {
  margin-top: 32px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  color: var(--fg);
  font-size: 1.2rem;
}

/* Back link on sub-pages */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}
.back-link:hover { text-decoration: underline; }
.back-top {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.back-top:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: #656d76;
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { margin: 0 6px; color: #b0b8c1; }
.breadcrumb-current { color: var(--fg); }

/* Post excerpt */
.post-excerpt {
  margin: 4px 0 0;
  color: #656d76;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Engagement bar (views + likes) */
.engagement-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 28px 0 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.engagement-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #656d76;
  font-size: 0.95rem;
}
.engagement-icon { font-size: 1.15rem; }
.like-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
  color: #656d76;
}
.like-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.like-btn.liked {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  cursor: default;
}

/* Nav search box */
.nav-search { display: inline-flex; align-items: center; margin-left: 8px; }
.nav-search-input {
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: var(--header-fg);
  font-size: 0.85rem;
  width: 150px;
  transition: all 0.2s;
}
.nav-search-input::placeholder { color: rgba(255,255,255,0.6); }
.nav-search-input:focus {
  outline: none;
  width: 200px;
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}

/* Search page */
.search-box-page { margin-bottom: 24px; }
.search-input-large {
  width: 100%;
  padding: 12px 16px;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s;
}
.search-input-large:focus {
  outline: none;
  border-color: var(--accent);
}
.search-hint, .search-no-results { color: #656d76; font-size: 0.95rem; }
.search-count { color: #656d76; font-size: 0.95rem; margin-bottom: 16px; }
.search-section {
  font-size: 1rem;
  color: var(--accent);
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Home search */
.home-search { margin-bottom: 28px; }
.home-search .search-input-large { margin-bottom: 0; }

@media (max-width: 768px) {
  .nav-search-input { width: 120px; }
  .nav-search-input:focus { width: 160px; }
}
