:root {
  /* ── Warm light palette (bg per spec, text/link à la huyenchip.com) ── */
  --bg:           #faf9f5;
  --surface:      #f4f1ea;
  --surface-2:    #ece8dd;
  --border:       #e5e0d4;
  --border-soft:  #efebe0;
  --text:         #111111;
  --text-muted:   #6f6c62;
  --link:         #4d74eb;
  --link-visited: #1337a6;
  --link-hover:   #111111;
  --accent:       #4d74eb;
  --accent-soft:  rgba(77, 116, 235, 0.10);
  --code-bg:      #f0ece2;
  --code-text:    #3f3d36;

  --font-serif: 'Lora', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #cfc9bb var(--bg);
}

::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background-color: #d3cdbf; border-radius: 4px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background-color: #bdb6a5; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern" 1;
  font-kerning: normal;
}

/* ── Typography ────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.25;
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.375rem;
  font-weight: 600;
  margin-top: 0;
}
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
h5, h6 { font-size: 1rem; color: var(--text-muted); }

p { margin: 0 0 1.15rem; }

b, strong { font-weight: 600; }
em, i { font-style: italic; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:visited { color: var(--link-visited); }

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

ul, ol {
  padding-left: 1.5rem;
  margin: 0 0 1.15rem;
}

li { margin-bottom: 0.4rem; }

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 1.75rem 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.25rem 0;
}

/* ── Code ──────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: #2b2a24;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.6;
  margin: 1.75rem 0;
  font-size: 0.85em;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: 1em;
}

/* ── Blockquote ────────────────────────────────── */

blockquote {
  font-style: italic;
  color: var(--text-muted);
  margin: 1.75rem 0;
  padding: 0.75rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}

blockquote p { margin: 0; }

/* ── Navbar ────────────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 245, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.nav-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand a,
.brand a:hover {
  text-decoration: none;
  color: inherit;
}

.brand h1 span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
  border-bottom-color: var(--accent);
}

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

.social a {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
  border: none;
}

.social a:hover {
  color: var(--accent);
  text-decoration: none;
  border: none;
}

/* ── Article / Content ─────────────────────────── */

article {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ── Footer ────────────────────────────────────── */

.lowbar {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.lowbar-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Post cards (posts listing) ────────────────── */

article ul:has(li > a:only-child) {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

article ul li:has(> a:only-child) {
  list-style: none;
  margin-bottom: 0;
}

article ul li > a:only-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  font-size: 1.05rem;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

article ul li > a:only-child:visited { color: var(--text); }

article ul li > a:only-child::after {
  content: '→';
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 1rem;
  transition: color 0.15s ease, transform 0.15s ease;
}

article ul li > a:only-child:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}

article ul li > a:only-child:hover::after {
  color: var(--accent);
  transform: translateX(4px);
}

/* ── Tags ──────────────────────────────────────── */

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.01em;
}

.tag--sm {
  font-size: 0.68rem;
  padding: 0.15em 0.5em;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}

/* ── Search ────────────────────────────────────── */

.search-wrap {
  position: relative;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  width: 200px;
  outline: none;
  transition: border-color 0.15s ease, width 0.2s ease;
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  width: 260px;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(60, 50, 30, 0.14);
  list-style: none;
  margin: 0;
  padding: 0.375rem;
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  list-style: none;
}

.search-result-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s ease;
}

.search-result-link:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}

.result-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

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

.search-no-results {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

mark {
  background: rgba(77, 116, 235, 0.16);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.1em;
  font-weight: 600;
}

/* ── Responsive / Mobile ───────────────────────── */

@media (max-width: 768px) {
  body { font-size: 1rem; }

  .nav-inner {
    height: auto;
    flex-wrap: wrap;
    padding: 0.65rem 1rem;
    gap: 0.65rem 1rem;
  }

  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.9rem 1.25rem;
  }

  .search-wrap {
    order: 3;
    flex: 1 1 100%;
  }

  .search-input,
  .search-input:focus { width: 100%; }

  .search-results {
    width: 100%;
    left: 0;
    right: 0;
  }

  article { padding: 2.25rem 1.15rem 3rem; }

  h1 { font-size: 1.95rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .brand h1 { font-size: 1.3rem; }
  article { padding: 1.75rem 1rem 2.5rem; }
  pre { padding: 1rem 1.1rem; }
  blockquote { padding: 0.6rem 1.1rem; }

  article ul li > a:only-child {
    padding: 1rem 1.1rem;
    font-size: 1rem;
  }
}
