:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e5e7eb;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 18px 36px rgba(15, 23, 42, 0.12);
  --radius-md: 12px;
  --radius-lg: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.container {
  width: min(1120px, 92%);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.navbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 70px;
  flex-wrap: wrap;
  padding: 0.75rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  margin-right: auto;
}

.brand img {
  height: 52px;
  width: auto;
  object-fit: contain;
}

.nav-toggle {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  place-content: center;
  gap: 4px;
  cursor: pointer;
}

.nav-toggle span:not(.sr-only) {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}

.category-nav-wrapper {
  display: none;
  width: 100%;
  flex-basis: 100%;
}

.category-nav-wrapper.open {
  display: block;
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0 1rem;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.category-list li {
  flex: 0 0 auto;
}

.category-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-pill:hover,
.category-pill:focus-visible {
  border-color: #c7d2fe;
  color: var(--primary);
}

.category-pill.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.page-content {
  padding: 1rem 0 2rem;
}

body[data-page="post"] .page-content {
  padding: 0;
}

body[data-page="post"] main.container.page-content {
  width: 100%;
  margin: 0;
}

body[data-page="home"] main.container.page-content {
  width: 100%;
  margin: 0;
  padding: 0.9rem;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2rem);
}

.page-heading p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
}

.status-message {
  margin-top: 0;
  min-height: 0;
  color: var(--text-muted);
  display: none;
}

.status-message.is-visible {
  display: block;
  margin-top: 0.6rem;
}

.status-message.error {
  color: #b91c1c;
}

.inline-loader {
  width: 34px;
  height: 34px;
  margin: 0.75rem auto 0;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.posts-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.post-card-link {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.post-image-wrap {
  aspect-ratio: 16 / 9;
  background: #eef2f7;
  overflow: hidden;
}

.post-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.post-card:hover .post-image {
  transform: scale(1.04);
}

.post-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.8rem;
}

.post-meta {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
}

.post-title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.35;
}

.post-excerpt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  padding: 0.7rem 1rem;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--primary-hover);
}

.btn-secondary {
  margin-top: auto;
  width: fit-content;
  background: #eff6ff;
  color: var(--primary);
  padding: 0.5rem 0.8rem;
  font-size: 0.86rem;
}

.load-more-wrap {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
}

.post-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 0;
  margin-top: 0.35rem;
  width: 100%;
}

body[data-page="post"] .post-detail {
  margin-top: 0;
  border-radius: 0;
  padding: 0.9rem;
}

.post-detail-meta {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
}

.post-detail h1 {
  margin: 0;
  line-height: 1.25;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
}

.post-detail-image-wrap {
  margin-top: 0.45rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #eef2f7;
}

.post-detail-image-wrap img {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
}

.post-detail-content {
  margin-top: 0.5rem;
  color: #111827;
}

.post-detail-content p,
.post-detail-content ul,
.post-detail-content ol,
.post-detail-content h2,
.post-detail-content h3,
.post-detail-content h4 {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.post-detail-content ul,
.post-detail-content ol {
  padding-left: 1rem;
}

.post-detail-content h2,
.post-detail-content h3,
.post-detail-content h4 {
  line-height: 1.3;
}

.post-detail-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-detail-content img {
  border-radius: 12px;
  margin: 0.75rem 0;
}

.post-detail-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border-radius: 10px;
}

.best-posts {
  margin-top: 1rem;
}

.best-posts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.best-posts-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.carousel-actions {
  display: flex;
  gap: 0.45rem;
}

.carousel-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.best-posts-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 0.8rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding-bottom: 0.2rem;
}

.best-post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.best-post-card a {
  display: block;
}

.best-post-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
}

.best-post-body {
  padding: 0.65rem 0.7rem 0.8rem;
}

.best-post-body h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  line-height: 1.35;
}

.best-post-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.site-footer-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

@media (min-width: 700px) {
  .posts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.2rem;
  }
}

@media (min-width: 920px) {
  .navbar {
    gap: 1.2rem;
    flex-wrap: nowrap;
    padding: 0;
  }

  .nav-toggle {
    display: none;
  }

  .category-nav-wrapper {
    display: block;
    width: auto;
    margin-left: auto;
  }

  .category-list {
    padding: 0;
    white-space: nowrap;
    overflow-x: visible;
  }

  .posts-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
