/* ─── Design tokens ─── */
:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --border: #e5e2dc;
  --border-f: #b0a89e;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --primary-color: #2563eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --sans: "Inter", system-ui, sans-serif;
  --max-w: 1080px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; font-family: var(--sans); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; font-size: 15px; line-height: 1.6; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ─── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.logo-sub {
  color: var(--muted);
  font-weight: 400;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.site-nav a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 5px;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--bg); }

.header-search {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color .15s;
}
.header-search:focus-within { border-color: var(--accent); }
.header-search input {
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  padding: 7px 12px;
  outline: none;
  width: 180px;
}
.header-search input::placeholder { color: #c0bab4; }
.header-search button {
  border: none;
  background: transparent;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color .15s;
}
.header-search button:hover { color: var(--accent); }
.header-search button svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Layout ─── */
.site-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 36px 24px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 40px;
  align-items: start;
  flex: 1;
  width: 100%;
}

/* ─── Main ─── */
.site-main {}

/* ─── Page header ─── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.back-link { font-size: 13px; color: var(--muted); text-decoration: none; margin-top: 6px; display: inline-block; }
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ─── Post list ─── */
.post-list { display: flex; flex-direction: column; gap: 20px; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  gap: 0;
  transition: box-shadow .15s, border-color .15s;
}
.post-card:hover { border-color: var(--border-f); box-shadow: 0 3px 10px rgba(0,0,0,.1); }

.card-image-wrap {
  flex-shrink: 0;
  width: 180px;
}
.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.card-cats { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: rgba(37,99,235,.08);
  border: 1px solid rgba(37,99,235,.15);
  border-radius: 4px;
  padding: 2px 8px;
  text-decoration: none;
  transition: background .15s;
}
.badge:hover { background: rgba(37,99,235,.14); text-decoration: none; }

.card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }

.card-excerpt {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}
.read-more { color: var(--accent); font-weight: 500; text-decoration: none; }
.read-more:hover { text-decoration: underline; }

/* ─── Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
  font-size: 13px;
  color: var(--muted);
}
.page-btn {
  display: inline-block;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.page-btn:hover { border-color: var(--border-f); background: var(--bg); text-decoration: none; }

/* ─── Empty state ─── */
.empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

/* ─── Single post ─── */
.single-post {}

.post-cover {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.post-header { margin-bottom: 32px; }
.post-header h1 { font-size: 28px; font-weight: 700; line-height: 1.25; margin: 12px 0 10px; }
.post-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.post-meta { font-size: 13px; color: var(--muted); }

/* ─── Prose ─── */
.prose {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
}
.prose h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 2em 0 1em;
  position: relative;
  padding-bottom: 12px;
}
.prose h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 70px;
  height: 3px;
  background-color: var(--primary-color);
}
.prose h3 { font-size: 17px; font-weight: 600; margin: 1.75em 0 .6em; }

/* ─── Table of contents ─── */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
  overflow: hidden;
}
.toc-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  gap: 10px;
}
.toc-toggle::-webkit-details-marker { display: none; }
.toc-toggle::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s;
  flex-shrink: 0;
  margin-top: -3px;
}
.toc[open] .toc-toggle::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}
.toc-toggle:hover { background: var(--bg); }
.toc-nav {
  border-top: 1px solid var(--border);
  padding: 12px 18px 16px;
}
.toc-nav ol {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toc-nav li { font-size: 13px; }
.toc-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.toc-nav a:hover { color: var(--accent); }
.prose p { margin-bottom: 1.25em; }
.prose ul, .prose ol { margin: 0 0 1.25em 1.5em; }
.prose li { margin-bottom: .4em; }
.prose blockquote {
  border-left: 3px solid var(--border-f);
  padding: .5em 0 .5em 1.2em;
  margin: 1.5em 0;
  color: var(--muted);
  font-style: italic;
}
.prose strong { font-weight: 600; }
.prose a { color: var(--accent); }
.prose img { border-radius: 6px; margin: 1.5em 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.prose code {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.prose pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 16px; overflow-x: auto; margin: 1.5em 0; }
.prose pre code { background: none; border: none; padding: 0; font-size: 13px; }

/* ─── Related posts ─── */
.related-posts { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.section-title { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 16px; }
.related-grid { display: flex; flex-direction: column; gap: 10px; }
.related-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  transition: border-color .15s;
}
.related-card:hover { border-color: var(--border-f); text-decoration: none; }
.related-title { font-size: 14px; color: var(--text); font-weight: 500; }
.related-date { font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ─── Search page ─── */
.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}
.search-form input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-form button {
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.search-form button:hover { background: var(--accent-h); }

.search-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.search-result:last-child { border-bottom: none; }
.search-result h3 { font-size: 16px; font-weight: 500; }
.search-result h3 a { color: var(--text); }
.search-result h3 a:hover { color: var(--accent); }
.search-result p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.search-result time { font-size: 12px; color: var(--muted); }
.search-count { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ─── Static pages ─── */
.static-page h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.static-page .page-intro { font-size: 15px; color: var(--muted); margin-bottom: 32px; }
.static-page section { margin-bottom: 36px; }
.static-page section h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.static-page section p, .static-page section li { font-size: 14px; line-height: 1.7; color: #3a3530; margin-bottom: 8px; }
.static-page section ul { margin-left: 20px; }
.static-page section a { color: var(--accent); }

.toolbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.toolbox-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  transition: border-color .15s;
}
.toolbox-item:hover { border-color: var(--border-f); text-decoration: none; }
.toolbox-item-title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.toolbox-item-desc { font-size: 12px; color: var(--muted); }

/* ─── Sidebar ─── */
.site-sidebar { display: flex; flex-direction: column; gap: 20px; }

.sidebar-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.widget-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.category-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.category-list li a {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  transition: color .15s;
}
.category-list li a::before { content: "›"; color: var(--muted); }
.category-list li a:hover { color: var(--accent); }

.sidebar-cta { background: rgba(37,99,235,.04); border-color: rgba(37,99,235,.15); }
.sidebar-cta p { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }
.btn-cta {
  display: block;
  text-align: center;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}
.btn-cta:hover { background: var(--accent-h); text-decoration: none; }

/* ─── Footer ─── */
.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}
.footer-inner nav { display: flex; gap: 16px; }
.footer-inner nav a { color: var(--muted); text-decoration: none; }
.footer-inner nav a:hover { color: var(--text); }

/* ─── 404 ─── */
.not-found {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 60px 24px;
  grid-column: 1 / -1;
}
.not-found-code { font-size: 72px; font-weight: 700; color: var(--border); line-height: 1; }
.not-found h1 { font-size: 22px; font-weight: 600; }
.not-found p { font-size: 14px; color: var(--muted); }
.not-found a { color: var(--accent); font-weight: 500; }

/* ─── Mobile nav (hidden on desktop) ─── */
.mobile-nav { display: none; }

/* ─── Mobile categories dropdown (hidden on desktop) ─── */
.mobile-cats-dropdown { display: none; }
.mobile-cats-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .15s;
}
.mobile-cats-toggle::-webkit-details-marker { display: none; }
.mobile-cats-dropdown[open] .mobile-cats-toggle {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.mobile-cats-toggle::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s;
  flex-shrink: 0;
  margin-top: -3px;
}
.mobile-cats-dropdown[open] .mobile-cats-toggle::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}
.mobile-cats-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-cats-label svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  flex-shrink: 0;
}
.mobile-cats-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  overflow: hidden;
}
.mobile-cat-link {
  display: block;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .12s, color .12s;
}
.mobile-cat-link:last-child { border-bottom: none; }
.mobile-cat-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.mobile-cat-link.active { color: var(--accent); font-weight: 500; background: rgba(37,99,235,.04); }

/* ─── Responsive ─── */
@media screen and (max-width: 1024px) {
  /* Layout */
  .site-layout {
    grid-template-columns: 1fr;
    padding: 24px 16px;
    gap: 28px;
  }
  body {
    padding-bottom: calc(55px + env(safe-area-inset-bottom));
  }

  /* Header — logo left, search right, nav hidden */
  .site-nav { display: none; }
  .header-search input { width: 130px; }

  /* Content */
  .card-image-wrap { width: 110px; }
  .toolbox-grid { grid-template-columns: 1fr; }
  .post-header h1 { font-size: 22px; }
  .header-search { margin-left: auto; }
  .footer-inner { flex-direction: column; align-items: center; gap: 10px; }
  .footer-inner nav { justify-content: center; flex-wrap: wrap; }

  /* Categories dropdown replaces sidebar */
  .mobile-cats-dropdown { display: block; margin-bottom: 20px; }
  .site-sidebar { display: none; }

  /* Bottom mobile nav */
  .mobile-nav {
    display: block;
    position: fixed;
    z-index: 1000;
    right: 0;
    bottom: 0;
    left: 0;
    height: 55px;
    background-color: #333;
    padding: 0 0 env(safe-area-inset-bottom) 0;
  }
  .mobile-nav-list {
    display: flex;
    height: 55px;
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .mobile-nav-item { flex: 1; }
  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 3px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .02em;
    transition: color .15s;
  }
  .mobile-nav-link:hover,
  .mobile-nav-link.active { color: #fff; text-decoration: none; }
  .mobile-nav-link svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

@media screen and (max-width: 480px) {
  /* On very small screens: hide the search input, keep the icon button */
  .header-search input { display: none; }
  .post-card { flex-direction: column; }
  .card-image-wrap { width: 100%; height: 160px; }
}
