/* =========================================================
   Sổ Tay Số — giao diện chính
   ========================================================= */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --surface-3: #e7ebf3;
  --text: #0e1526;
  --text-2: #364057;
  --muted: #5d6780;
  --border: #e2e6ef;
  --primary: #2f6bff;
  --primary-2: #1f56e0;
  --primary-soft: #e8efff;
  --accent: #12b886;
  --warn: #e8590c;
  --warn-soft: #fff4e6;
  --danger: #e03131;
  --danger-soft: #fff0f0;
  --tip-soft: #e6fcf5;
  --info-soft: #e7f5ff;
  --code-bg: #0f1729;
  --code-text: #dbe4ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 64px;
  --maxw: 1200px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --tile-l: 94%;
  --tile-s: 85%;
  --tile-fg-l: 42%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e17;
    --surface: #111827;
    --surface-2: #172033;
    --surface-3: #1f2a40;
    --text: #e8ecf5;
    --text-2: #c3cad9;
    --muted: #8f9bb3;
    --border: #232e45;
    --primary: #5b8cff;
    --primary-2: #7aa2ff;
    --primary-soft: #18264a;
    --warn-soft: #2b1d10;
    --danger-soft: #2d1416;
    --tip-soft: #0f2a22;
    --info-soft: #10233a;
    --code-bg: #070b14;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --tile-l: 18%;
    --tile-s: 45%;
    --tile-fg-l: 72%;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #172033;
  --surface-3: #1f2a40;
  --text: #e8ecf5;
  --text-2: #c3cad9;
  --muted: #8f9bb3;
  --border: #232e45;
  --primary: #5b8cff;
  --primary-2: #7aa2ff;
  --primary-soft: #18264a;
  --warn-soft: #2b1d10;
  --danger-soft: #2d1416;
  --tip-soft: #0f2a22;
  --info-soft: #10233a;
  --code-bg: #070b14;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  --tile-l: 18%;
  --tile-s: 45%;
  --tile-fg-l: 72%;
  color-scheme: dark;
}

/* ---------- Nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.015em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }
/* Tắt ligature của font mono: >= phải hiện đúng là >=, không thành ≥ */
code, pre, kbd, .textarea, .kv dd { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
kbd {
  font-family: var(--mono);
  font-size: .78em;
  padding: .1em .45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; color: #fff; }

/* ---------- Thanh tiến trình đọc ---------- */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  z-index: 60; transition: width .1s linear;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.12rem; }
.brand:hover { color: var(--text); }
.brand-mark svg { width: 32px; height: 32px; display: block; }
.brand-text b { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.main-nav a {
  color: var(--text-2); font-weight: 500; font-size: .94rem;
  padding: 8px 12px; border-radius: 10px;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-trigger {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; height: 40px; padding: 0 8px 0 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--muted); font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search-trigger kbd { margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.menu-btn { display: none; }

@media (max-width: 1020px) {
  .search-trigger { min-width: 0; }
  .search-trigger-text, .search-trigger kbd { display: none; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 860px) {
  .menu-btn { display: grid; }
  .main-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 2px; margin: 0; padding: 12px 16px 20px;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    transform: translateY(-8px); opacity: 0; pointer-events: none; transition: .18s ease;
  }
  .main-nav.open { transform: none; opacity: 1; pointer-events: auto; }
  .main-nav a { padding: 12px 14px; font-size: 1rem; }
}

main { min-height: calc(100vh - var(--header-h) - 200px); outline: none; }

/* ---------- Nút & chip ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 600; font-size: .94rem;
  background: var(--primary); color: #fff; transition: transform .1s, background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--primary); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 10px; }
.btn.is-on { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: .84rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: .15s;
}
button.chip:hover, a.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
.lv-1 { background: var(--tip-soft); color: #0b7a5a; }
.lv-2 { background: var(--info-soft); color: #1864ab; }
.lv-3 { background: var(--warn-soft); color: #c2410c; }
:root[data-theme="dark"] .lv-1 { color: #63e6be; }
:root[data-theme="dark"] .lv-2 { color: #74c0fc; }
:root[data-theme="dark"] .lv-3 { color: #ffa94d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lv-1 { color: #63e6be; }
  :root:not([data-theme="light"]) .lv-2 { color: #74c0fc; }
  :root:not([data-theme="light"]) .lv-3 { color: #ffa94d; }
}

/* Ô icon màu theo danh mục */
.tile {
  --h: 215;
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: hsl(var(--h) var(--tile-s) var(--tile-l));
  color: hsl(var(--h) 70% var(--tile-fg-l));
}
.tile .ic { width: 22px; height: 22px; }
.tile-lg { width: 60px; height: 60px; border-radius: 16px; }
.tile-lg .ic { width: 30px; height: 30px; }
.tile-sm { width: 32px; height: 32px; border-radius: 9px; }
.tile-sm .ic { width: 17px; height: 17px; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 72px 0 56px; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% -10% auto; height: 640px; z-index: -1;
  background:
    radial-gradient(600px 300px at 20% 40%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%),
    radial-gradient(500px 280px at 80% 30%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%);
  filter: blur(10px);
}
.hero-inner { max-width: 820px; margin: 0 auto; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; font-size: .84rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.hero h1 { font-size: clamp(2rem, 5.2vw, 3.5rem); font-weight: 800; letter-spacing: -.03em; margin-bottom: 16px; }
.hero h1 .grad { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: clamp(1rem, 2.2vw, 1.18rem); color: var(--muted); max-width: 640px; margin: 0 auto 28px; }

.hero-search {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding: 8px 8px 8px 18px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.hero-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow); }
.hero-search .ic { color: var(--muted); }
.hero-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1.02rem; height: 44px; }
.hero-tags { margin-top: 18px; justify-content: center; }
.hero-tags span.muted { font-size: .86rem; align-self: center; }

.stats { display: flex; justify-content: center; gap: 12px 40px; flex-wrap: wrap; margin-top: 36px; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .88rem; }

/* ---------- Section ---------- */
.section { padding: 44px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 700; margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .92rem; }

/* ---------- Lưới danh mục ---------- */
.cat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.cat-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--text); }
.cat-card h3 { font-size: 1rem; margin: 0 0 4px; font-weight: 650; }
.cat-card p { font-size: .86rem; color: var(--muted); margin: 0 0 8px; line-height: 1.5; }
.cat-card .count { font-size: .78rem; font-weight: 600; color: var(--muted); }

/* ---------- Thẻ bài viết ---------- */
.post-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.post-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.post-card .top { display: flex; align-items: center; gap: 10px; }
.post-card .cat-name { font-size: .8rem; font-weight: 600; color: var(--muted); }
.post-card h2, .post-card h3 { font-size: 1.04rem; font-weight: 650; margin: 0; line-height: 1.4; }
.post-card :is(h2, h3) a { color: var(--text); }
.post-card :is(h2, h3) a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.post-card p { font-size: .9rem; color: var(--muted); margin: 0; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; font-size: .8rem; color: var(--muted); }
.post-meta .ic { width: 14px; height: 14px; }
.post-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.save-btn {
  position: relative; z-index: 2; margin-left: auto;
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted);
}
.save-btn:hover { background: var(--surface-2); color: var(--primary); }
.save-btn.saved { color: var(--primary); }
.save-btn.saved svg { fill: currentColor; }

/* Danh sách gọn */
.post-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.post-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: var(--text); border-top: 1px solid var(--border); }
.post-row:first-child { border-top: 0; }
.post-row:hover { background: var(--surface-2); color: var(--text); }
.post-row .t { font-weight: 600; font-size: .95rem; }
.post-row .s { font-size: .82rem; color: var(--muted); }
.post-row .grow { flex: 1; min-width: 0; }
.post-row .arrow { color: var(--muted); }

/* ---------- Công cụ ---------- */
.tool-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tool-card {
  display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--text); }
.tool-card h3 { font-size: 1rem; margin: 0; }
.tool-card p { font-size: .87rem; color: var(--muted); margin: 0; line-height: 1.5; }

.tool-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
@media (max-width: 600px) { .tool-panel { padding: 16px; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.textarea { min-height: 180px; resize: vertical; font-family: var(--mono); font-size: .9rem; line-height: 1.55; }
.textarea.prose { font-family: var(--font); font-size: .95rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .field { flex: 1 1 180px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.output {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 1.15rem; word-break: break-all;
  padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.output span { flex: 1; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.kv > div { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.kv dt { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 2px 0 0; font-family: var(--mono); font-size: .95rem; word-break: break-all; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .25s, background .25s; }
.err { color: var(--danger); font-size: .9rem; }
.ok { color: var(--accent); font-size: .9rem; }
.swatch { width: 100%; height: 120px; border-radius: 12px; border: 1px solid var(--border); }

.kb { display: flex; flex-direction: column; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.kb-row { display: flex; gap: 6px; }
.kb-key {
  flex: none; min-width: 42px; height: 42px; padding: 0 8px; border-radius: 8px;
  display: grid; place-items: center; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 3px; color: var(--text-2);
  transition: background .1s;
}
.kb-key.down { background: var(--primary); color: #fff; border-color: var(--primary-2); }
.kb-key.done { background: var(--tip-soft); border-color: var(--accent); color: var(--text); }

/* ---------- Bố cục trang con ---------- */
.page-head { padding: 40px 0 24px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -.025em; margin-bottom: 8px; }
.page-head .lead { color: var(--muted); font-size: 1.05rem; max-width: 720px; margin: 0; }
.page-head-row { display: flex; gap: 18px; align-items: center; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { opacity: .5; }

.layout-side { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; padding-bottom: 56px; }
.side-nav { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto; }
.side-title, .toc .side-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px 10px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; font-size: .9rem; color: var(--text-2); }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-nav a .n { margin-left: auto; font-size: .76rem; color: var(--muted); }
@media (max-width: 900px) {
  .layout-side { grid-template-columns: 1fr; }
  .layout-side > .side-nav { display: none; }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.toolbar .select { width: auto; padding: 7px 10px; font-size: .88rem; }

/* ---------- Trang bài viết ---------- */
.article-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 48px; padding-bottom: 64px; }
@media (max-width: 1020px) { .article-wrap { grid-template-columns: 1fr; } .toc { display: none; } }
.article-head { padding: 32px 0 8px; max-width: 780px; }
.article-head h1 { font-size: clamp(1.7rem, 4.2vw, 2.5rem); font-weight: 800; letter-spacing: -.028em; margin-bottom: 14px; }
.article-head .summary { font-size: 1.1rem; color: var(--muted); margin-bottom: 18px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: .87rem; color: var(--muted); }
.article-meta > span, .article-meta > a { display: inline-flex; align-items: center; gap: 6px; }
.article-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }

.prose { max-width: 780px; font-size: 1.03rem; color: var(--text-2); }
.prose h2 { font-size: 1.45rem; color: var(--text); margin: 2em 0 .6em; scroll-margin-top: calc(var(--header-h) + 20px); font-weight: 700; }
.prose h3 { font-size: 1.15rem; color: var(--text); margin: 1.6em 0 .5em; scroll-margin-top: calc(var(--header-h) + 20px); }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--text); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--primary) 40%, transparent); text-underline-offset: 3px; }
.prose code {
  font-family: var(--mono); font-size: .86em;
  padding: .12em .4em; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.prose pre {
  position: relative; margin: 0 0 1.3em; padding: 18px 18px; border-radius: 12px;
  background: var(--code-bg); color: var(--code-text); overflow-x: auto;
  font-family: var(--mono); font-size: .88rem; line-height: 1.7; border: 1px solid #1d2840;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose pre .cmt { color: #7f8db3; }
.copy-code {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px; font-size: .76rem; font-family: var(--font);
  border: 1px solid #2c3a5a; background: #18223a; color: #c9d4f2; opacity: .85;
}
.copy-code:hover { opacity: 1; color: #fff; }
.table-wrap { overflow-x: auto; margin: 0 0 1.3em; }
.prose table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.prose th, .prose td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); color: var(--text); font-weight: 600; white-space: nowrap; }
.prose td kbd { white-space: nowrap; }
.prose img { border-radius: 12px; border: 1px solid var(--border); }

.prose ol.steps { list-style: none; counter-reset: s; padding-left: 0; }
.prose ol.steps > li { counter-increment: s; position: relative; padding: 2px 0 2px 46px; margin: 0 0 14px; }
.prose ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .88rem;
}
.prose ol.steps > li::after { content: ""; position: absolute; left: 14.5px; top: 34px; bottom: -12px; width: 1px; background: var(--border); }
.prose ol.steps > li:last-child::after { display: none; }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; margin: 0 0 1.3em; border: 1px solid transparent; font-size: .97rem; }
.callout > .ic { margin-top: 3px; }
.callout > div > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: 2px; }
.callout.tip { background: var(--tip-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.callout.tip > .ic { color: var(--accent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn > .ic { color: var(--warn); }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.callout.info > .ic { color: var(--primary); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger > .ic { color: var(--danger); }

.toc { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; padding-top: 36px; max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto; }

#toc-links a { display: block; padding: 5px 0 5px 14px; font-size: .87rem; color: var(--muted); border-left: 2px solid var(--border); line-height: 1.45; }
#toc-links a:hover { color: var(--text); }
#toc-links a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.toc .tool-promo { margin-top: 24px; padding: 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: .87rem; }

.feedback {
  max-width: 780px; margin: 40px 0 0; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.feedback b { font-size: 1rem; }
.pager { max-width: 780px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.pager a { padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.pager a:hover { border-color: var(--primary); color: var(--text); }
.pager a small { color: var(--muted); font-size: .8rem; }
.pager a b { font-weight: 600; font-size: .94rem; line-height: 1.4; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: auto; } }

/* ---------- Tìm kiếm ---------- */
.search-box { display: flex; gap: 10px; margin-bottom: 18px; }
.search-box .input { height: 48px; font-size: 1.02rem; }
mark { background: color-mix(in srgb, #ffd43b 55%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }

.palette { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 22, .55); backdrop-filter: blur(3px); animation: fade .15s; }
.palette-panel {
  position: relative; width: 100%; max-width: 640px; max-height: 72vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop .16s ease-out;
}
.palette-input { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 1.05rem; color: var(--text); min-width: 0; }
.palette-input kbd { cursor: pointer; }
.palette-results { overflow-y: auto; padding: 8px; }
.palette-group { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; color: var(--text); }
.palette-item .grow { flex: 1; min-width: 0; }
.palette-item .t { display: block;  font-weight: 600; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .s { display: block;  font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item.sel { background: var(--primary-soft); color: var(--text); }
.palette-item.sel .t { color: var(--primary); }
.palette-empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }
@media (max-width: 600px) { .palette { padding-top: 12px; } .palette-foot { display: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

/* ---------- Trạng thái rỗng, CTA ---------- */
.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.empty .tile { margin: 0 auto 14px; }
.empty h2 { font-size: 1.25rem;  margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

.cta {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  padding: 32px; border-radius: 20px; color: #fff;
  background: linear-gradient(120deg, #2f6bff, #1b4fd6 45%, #0f9f74);
  box-shadow: var(--shadow);
}
.cta h2 { margin: 0 0 6px; font-size: 1.5rem; }
.cta p { margin: 0; opacity: .9; }
.cta .btn { background: #fff; color: #1b4fd6; }
.cta .btn:hover { background: #eef3ff; color: #1b4fd6; }
@media (max-width: 700px) { .cta { grid-template-columns: 1fr; padding: 24px; } }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.shortcut-card { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.shortcut-card h3 { font-size: 1.02rem; display: flex; align-items: center; gap: 10px; }
.sc-list { list-style: none; padding: 0; margin: 0; }
.sc-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.sc-list li:first-child { border-top: 0; }
.sc-list kbd { font-size: .74rem; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 32px; padding: 44px 16px 28px; }
.footer-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-grid ul a { color: var(--text-2); font-size: .92rem; }
.footer-grid ul a:hover { color: var(--primary); }
.footer-grid p { font-size: .9rem; margin-top: 10px; max-width: 340px; }
.footer-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--border); font-size: .86rem; color: var(--muted); }
@media (min-width: 768px) { .footer-grid { padding-left: 24px; padding-right: 24px; } }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }

/* ---------- Liên hệ & Zalo ---------- */
.toc .side-title { margin-left: 0; margin-bottom: 10px; }
.btn-zalo { background: #0068ff; color: #fff; }
.btn-zalo:hover { background: #0052cc; color: #fff; }
.zalo-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  display: inline-flex; align-items: center; gap: 8px;
  height: 50px; padding: 0 18px 0 15px; border-radius: 999px;
  background: #0068ff; color: #fff; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 104, 255, .38);
  transition: transform .15s, box-shadow .15s;
}
.zalo-float:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 104, 255, .45); }
.zalo-float .ic { width: 22px; height: 22px; }
@media (max-width: 600px) { .zalo-float { right: 14px; bottom: 14px; height: 48px; padding: 0 16px 0 14px; } }

.contact-card { padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); align-self: start; }
.contact-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.contact-head b { display: block; font-size: 1.15rem; }
.contact-head .muted { font-size: .9rem; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 1.4rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent));
}
.ask-box {
  max-width: 780px; margin-top: 16px; padding: 18px 20px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}
.ask-box > .ic { color: var(--primary); width: 24px; height: 24px; }
.ask-box > div { flex: 1 1 260px; }
.ask-box p { margin: 2px 0 0; font-size: .92rem; }
.tool-guide { margin-top: 32px; }
.tool-guide h2:first-child { margin-top: 0; }
.related { margin-top: 8px; }
.footer-contact li:first-child { font-weight: 600; color: var(--text); font-size: .95rem; }

/* ---------- Thông báo nhỏ ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 95;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 12px; font-size: .92rem; font-weight: 500;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fade-in { animation: fadeUp .28s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- In ấn ---------- */
@media print {
  .site-header, .site-footer, .toc, .article-actions, .feedback, .pager, .related, .progress, .copy-code, .crumbs, .zalo-float, .ask-box { display: none !important; }
  body { background: #fff; color: #000; }
  .article-wrap { display: block; }
  .prose { max-width: none; color: #000; }
  .prose pre { background: #f4f4f4; color: #000; border-color: #ccc; }
}
