:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c1d22;
  --muted: #5d6170;
  --border: #e2e4ec;
  --primary: #1f5fe0;
  --primary-hover: #174bb4;
  --primary-text: #ffffff;
  --new: #0f7a54;
  --new-bg: #e3f6ee;
  --warn-bg: #fff4e0;
  --warn-text: #7a4b00;
  --code-bg: #eef0f6;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 24px rgb(0 0 0 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --surface: #1c1e24;
    --text: #eceef3;
    --muted: #a3a8b8;
    --border: #2d3039;
    --primary: #6b97ff;
    --primary-hover: #8aaeff;
    --primary-text: #0b1020;
    --new: #5fd6a4;
    --new-bg: #143327;
    --warn-bg: #3a2c12;
    --warn-text: #ffd796;
    --code-bg: #262932;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

/* Thuộc tính hidden luôn ẩn, kể cả khi class có đặt display. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

main { display: block; min-height: 60vh; }
/* Lưới an toàn: không bao giờ cho trang kéo ngang được (trên điện thoại sẽ lộ vùng trắng bên phải). */
body { overflow-x: clip; }

/* Cân dòng: tiêu đề chia đều các dòng, đoạn văn tránh một chữ đứng lẻ ở dòng cuối. */
h1, h2, h3, .app-tagline, .post-title { text-wrap: balance; }
p, li, dd, blockquote { text-wrap: pretty; }
main:focus { outline: none; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

a { color: var(--primary); }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, .chip:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.38em;
  border-radius: 5px;
  word-break: break-word;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 20;
}
.skip-link:focus { left: 8px; }

.muted { color: var(--muted); }
.empty { padding: 32px 0; color: var(--muted); text-align: center; }

/* ---------- Header / footer ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-size: 1.2rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand img { display: block; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
}
.main-nav a:hover { color: var(--text); background: var(--surface); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--surface); font-weight: 600; }
.header-search { margin-left: auto; }
.header-search input { width: 220px; }
/* Nút chuyển Tiếng Việt <-> English */
.lang-switch {
  display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border, rgba(127, 127, 127, .35)); color: var(--text); font-size: .9rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.lang-switch:hover { background: var(--surface); }

input[type="search"], select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  min-height: 42px;
}
input[type="search"]::placeholder { color: var(--muted); }

.site-footer { margin-top: 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.92rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 24px; padding-bottom: 32px; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-inner a { color: var(--muted); }

/* ---------- Sections ---------- */
.hero { padding: 64px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.02em; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 0; }
.hero-search { display: flex; gap: 8px; max-width: 560px; margin: 28px auto 0; }
.hero-search input { flex: 1; min-height: 48px; font-size: 1.05rem; }
.notice {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.section { padding: 28px 20px; }
.section h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 6px; letter-spacing: -0.02em; line-height: 1.2; }
.section h2 { font-size: 1.45rem; margin: 0 0 16px; letter-spacing: -0.01em; }
.section .app-name, .section .post-title { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.page-lead { margin: 0 0 20px; font-size: 1.05rem; }

.breadcrumb ol { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 6px; font-size: 0.9rem; color: var(--muted); min-width: 0; }
.breadcrumb li { white-space: nowrap; }
.breadcrumb li:last-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--border); }
.breadcrumb a { color: var(--muted); }

/* ---------- Buttons, badges, chips, tags ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 18px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); padding-left: 10px; padding-right: 10px; }
.btn-ghost:hover { color: var(--text); }
.btn[aria-disabled="true"] { background: var(--border); color: var(--muted); pointer-events: none; }

.badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 8px;
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0;
}
.badge-version { background: var(--border); color: var(--text); }
.badge-new { background: var(--new-bg); color: var(--new); }
.badge-draft { background: var(--warn-bg); color: var(--warn-text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); }
.chip[aria-pressed="true"], .chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.count { font-size: 0.8em; opacity: 0.75; }

.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.tag {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  text-decoration: none;
}
.tag:hover { color: var(--primary); border-color: var(--primary); }
.tag-more { color: var(--primary); }
.tag-list-lg .tag { font-size: 1rem; padding: 6px 14px; background: var(--surface); }
.tag-cloud { margin: 0 0 24px; }

/* ---------- Filter / search bars ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.filter-search { flex: 1 1 320px; }
.filter-search input { width: 100%; }
.filter-sort { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.92rem; }
.result-count { margin: 0 0 14px; font-size: 0.92rem; }

/* ---------- App cards ----------
   Mỗi phần có vị trí và chiều cao cố định để các thẻ cạnh nhau luôn thẳng hàng. */
.app-grid > .app-card { min-width: 0; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 20px; }
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.app-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.app-head { display: flex; gap: 14px; align-items: center; min-width: 0; }
.app-head > a { flex: none; line-height: 0; }
.app-icon { width: 56px; height: 56px; border-radius: 13px; }
.app-head-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.app-name {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-name a { color: var(--text); text-decoration: none; }
.app-name a:hover { color: var(--primary); text-decoration: underline; }
.app-badges { display: flex; align-items: center; gap: 6px; min-height: 22px; flex-wrap: nowrap; }
.app-card .app-tagline {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  min-height: 3em;                       /* luôn chừa đủ 2 dòng */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-meta { margin: 0; color: var(--muted); font-size: 0.88rem; }
.app-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-card-actions { flex-direction: column; flex-wrap: nowrap; margin-top: auto; padding-top: 4px; }
.app-card-actions > .btn-primary { width: 100%; }
.app-actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }   /* màn hình hẹp: nút xuống dòng thay vì tràn */
.app-actions-row .btn-ghost { flex: none; }

/* ---------- App detail ---------- */
.update-banner {
  margin: 0 0 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--new-bg);
  border: 1px solid color-mix(in srgb, var(--new) 40%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.update-banner p { margin: 0; }

.app-hero { display: flex; gap: 28px; align-items: center; margin: 8px 0 36px; }
.app-icon-lg { width: 128px; height: 128px; border-radius: 28px; flex: none; }
.app-hero-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.app-hero h1 { margin: 0; }
.app-hero .app-tagline { font-size: 1.15rem; margin: 0; color: var(--muted); }
.app-hero .app-actions { margin-top: 4px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.detail-main > section { margin-bottom: 28px; }
.detail-main h2 { font-size: 1.3rem; margin: 0 0 10px; }
.detail-main ul, .detail-main ol { padding-left: 22px; margin: 0; }
.detail-main li { margin: 4px 0; }
.detail-side {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.side-title { font-size: 1rem !important; margin: 0 !important; }
.info-list { margin: 0; display: grid; gap: 0; }
.info-list div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.info-list div:first-child { padding-top: 0; }
.info-list dt { color: var(--muted); white-space: nowrap; }
.info-list dd { margin: 0; text-align: right; font-weight: 500; }
.info-block h3 { margin: 0 0 4px; font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.info-block p { margin: 0; font-weight: 500; }
.sha { margin: 0; color: var(--muted); font-size: 0.78rem; }
.sha code { word-break: break-all; }
.related { margin-top: 40px; }

/* ---------- Posts ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 20px; }
.post-list { display: grid; gap: 16px; max-width: 820px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.post-cover img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }
.post-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-title { margin: 0; font-size: 1.15rem; line-height: 1.4; }
.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { color: var(--primary); text-decoration: underline; }
.post-meta { margin: 0; color: var(--muted); font-size: 0.85rem; }
.post-summary { margin: 0; color: var(--muted); line-height: 1.55; }
.post-card .tag-list { margin-top: auto; padding-top: 6px; }
/* Dạng lưới (trang chủ, bài liên quan): giới hạn số dòng để các thẻ thẳng hàng. */
.post-grid .post-title {
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-grid .post-summary {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-list .post-title { font-size: 1.3rem; }

.post { max-width: 820px; }
.post-header { margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.post-header h1 { margin: 0; }
.post-cover-lg { width: 100%; border-radius: var(--radius); margin-bottom: 24px; }

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 28px;
}
.toc h2 { font-size: 1rem; margin: 0 0 8px; }
/* Số thứ tự chỉ đếm mục cấp 2; mục con cấp 3 (vd nhật ký từng phiên bản) hiện chấm, không làm nhảy số. */
.toc ol { margin: 0; padding-left: 0; list-style: none; counter-reset: toc; }
.toc li { margin: 3px 0; position: relative; }
.toc .toc-l2 { counter-increment: toc; padding-left: 26px; }
.toc .toc-l2::before { content: counter(toc) "."; position: absolute; left: 0; width: 20px; text-align: right; color: var(--muted); }
.toc .toc-l3 { margin-left: 26px; padding-left: 18px; }
.toc .toc-l3::before { content: "◦"; position: absolute; left: 4px; color: var(--muted); }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; }
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
}
.post-nav .older { text-align: right; grid-column: 2; }
.post-nav span.muted { font-weight: 400; font-size: 0.88rem; }

/* ---------- Trang chủ ---------- */
.hero-home {
  padding: 56px 0 44px;
  background:
    radial-gradient(60% 80% at 15% 0%, color-mix(in srgb, #5c9eff 22%, transparent), transparent 70%),
    radial-gradient(50% 70% at 90% 10%, color-mix(in srgb, #8b5cf6 18%, transparent), transparent 70%);
  border-bottom: 1px solid var(--border);
}
.hero-icons { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin: 0 0 28px; padding: 0; }
.hero-icons li { animation: float 6s ease-in-out infinite; animation-delay: calc(var(--i) * -0.7s); }
.hero-icons img { display: block; width: 64px; height: 64px; filter: drop-shadow(0 8px 14px rgb(0 0 0 / 0.14)); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .hero-icons li { animation: none; } }
.hero-stats { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 10px; margin: 22px 0 0; padding: 0; }
.hero-stats li {
  padding: 6px 14px; border-radius: 999px; font-size: 0.92rem; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border);
}
.hero-stats strong { color: var(--text); }
.section-lead { margin: 4px 0 0; color: var(--muted); }

.category-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.category-card {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.category-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.category-emoji { font-size: 1.8rem; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--bg); flex: none; }
.category-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.category-text .muted { font-size: 0.88rem; }
.category-apps { display: flex; flex: none; }
.category-apps img { border-radius: 7px; margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }

.why-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.why-grid li { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.why-icon { font-size: 1.6rem; }
.why-grid h3 { margin: 8px 0 6px; font-size: 1.05rem; }
.why-grid p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.steps-band {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 28px; border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
}
.steps-band h2 { margin: 0 0 14px; }
.steps-row { list-style: none; counter-reset: s; display: flex; flex-wrap: wrap; gap: 14px 28px; margin: 0; padding: 0; }
.steps-row li { counter-increment: s; display: flex; flex-direction: column; max-width: 260px; padding-left: 40px; position: relative; }
.steps-row li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: var(--primary-text); font-weight: 700; display: grid; place-items: center; font-size: 0.9rem;
}
.steps-row span { color: var(--muted); font-size: 0.92rem; }

/* Lưới bài viết 3 cột (trang Bài viết, trang thẻ) */
.post-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .post-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .post-grid-3 { grid-template-columns: 1fr; } }

/* ---------- Hàng cuộn ngang (trang chủ) ---------- */
.section-head-actions { display: flex; align-items: center; gap: 14px; }
@media (max-width: 640px) {
  .section-head-actions { width: 100%; justify-content: space-between; }
}
.carousel-buttons { display: flex; gap: 6px; }
.carousel-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.carousel-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.carousel-btn:disabled { opacity: 0.35; cursor: default; }
.carousel {
  position: relative;                 /* để chữ ẩn (position: absolute) trong thẻ bị cắt theo khung cuộn, không làm cả trang rộng ra */
  display: grid;
  grid-auto-flow: column;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 2px;
  padding: 4px 2px 14px;              /* chừa chỗ cho bóng đổ và thanh cuộn */
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.carousel-apps { grid-auto-columns: min(340px, 90%); }
@media (max-width: 420px) {
  .app-actions-row .btn-ghost { padding-left: 6px; padding-right: 6px; }
}
.carousel-posts { grid-auto-columns: min(320px, 82%); }
.carousel > * { scroll-snap-align: start; }
.carousel .post-title {
  min-height: 2.8em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.carousel .post-summary { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.carousel-more {
  display: grid; place-items: center; text-align: center; padding: 24px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  font-weight: 600; text-decoration: none; min-width: 200px;
}
.carousel-more:hover { border-color: var(--primary); background: var(--surface); }
@media (prefers-reduced-motion: reduce) { .carousel { scroll-behavior: auto; } }

.pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.pagination button { font: inherit; color: var(--primary); background: transparent; cursor: pointer; }
.pagination button:disabled { color: var(--muted); cursor: default; opacity: 0.5; }
.pagination ol { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.pagination a, .pagination span[aria-current], .pagination button {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
}
.pagination span[aria-current], .pagination button[aria-current] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }

/* ---------- Nội dung Markdown ---------- */
.prose { font-size: 1.05rem; line-height: 1.75; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.5rem; margin: 2em 0 0.6em; line-height: 1.3; scroll-margin-top: 88px; }
.prose h3 { font-size: 1.2rem; margin: 1.6em 0 0.5em; scroll-margin-top: 88px; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: 0.3em 0; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose blockquote {
  margin-left: 0;
  padding: 12px 18px;
  border-left: 4px solid var(--primary);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.5;
}
.prose pre code { background: none; padding: 0; font-size: 0.9em; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--surface); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
}

/* ---------- Tìm kiếm ---------- */
.search-form { margin-bottom: 8px; }
.search-results { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 820px; }
.search-result {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.search-result img { border-radius: 11px; flex: none; }
.search-result h2 { font-size: 1.15rem; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-result p { margin: 0; }
.search-meta { font-size: 0.88rem; margin-bottom: 4px !important; }


.not-found { text-align: center; padding-top: 80px; padding-bottom: 80px; }
.not-found .app-actions { justify-content: center; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 860px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  /* Đầu trang gọn: logo, menu 1 hàng (vuốt ngang nếu dài), ô tìm kiếm; không dính khi cuộn. */
  .site-header { position: static; }
  .header-inner { gap: 8px 16px; padding-top: 10px; padding-bottom: 10px; }
  .main-nav {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -8px;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { white-space: nowrap; padding: 6px 10px; }
  .header-search { margin-left: auto; flex: 1 1 160px; }
  .header-search input { width: 100%; min-height: 38px; padding: 6px 12px; }
  .detail-side { top: auto; }
}
@media (max-width: 640px) {
  .app-hero { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 520px) {
  .app-grid, .post-grid { grid-template-columns: 1fr; }
  .hero-search { flex-direction: column; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .older { grid-column: 1; }
  .app-hero { gap: 16px; }
  .app-icon-lg { width: 96px; height: 96px; border-radius: 22px; }
}
