/* [HUONG-DAN] Kiểu chung cho Sổ tay (/huong-dan) và Trợ giúp (/tro-giup). */
:root {
  --paper: #faf8fc;
  --sheet: #ffffff;
  --ink: #221b30;
  --ink-soft: #5b5170;
  --ink-faint: #8a8199;
  --line: #e7e1ef;
  --line-strong: #d6cce3;
  --accent: #7a2fc9;
  --accent-soft: #f1e8fc;
  --accent-ink: #5a1fa0;
  --premium: #c2297a;
  --premium-soft: #fce8f2;
  --free: #1b7a4b;
  --free-soft: #e3f4ea;
  --alert: #c62828;
  --alert-soft: #fdeceb;
  --amber: #9a5b00;
  --amber-soft: #fdf3dc;
  --frame: #1d1726;
  --shadow: 0 1px 2px rgba(34, 27, 48, .06), 0 12px 32px rgba(74, 32, 128, .10);
  --display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15111d;
    --sheet: #1d1828;
    --ink: #ede8f5;
    --ink-soft: #b9afca;
    --ink-faint: #8c829e;
    --line: #2e2740;
    --line-strong: #3d3452;
    --accent: #c8a6ff;
    --accent-soft: #2d2143;
    --accent-ink: #dcc7ff;
    --premium: #ff8fc4;
    --premium-soft: #3a1a2c;
    --free: #7fd9a8;
    --free-soft: #173226;
    --alert: #ff8a80;
    --alert-soft: #3a1c1c;
    --amber: #f3c26b;
    --amber-soft: #33280f;
    --frame: #0b0910;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --paper: #15111d;
  --sheet: #1d1828;
  --ink: #ede8f5;
  --ink-soft: #b9afca;
  --ink-faint: #8c829e;
  --line: #2e2740;
  --line-strong: #3d3452;
  --accent: #c8a6ff;
  --accent-soft: #2d2143;
  --accent-ink: #dcc7ff;
  --premium: #ff8fc4;
  --premium-soft: #3a1a2c;
  --free: #7fd9a8;
  --free-soft: #173226;
  --alert: #ff8a80;
  --alert-soft: #3a1c1c;
  --amber: #f3c26b;
  --amber-soft: #33280f;
  --frame: #0b0910;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.shell {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1320px;
  margin: 0 auto;
  padding-inline: 20px;
}
@media (min-width: 1080px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); gap: 56px; padding-inline: 32px; }
}

/* ---------- mục lục ---------- */
.toc { padding-block: 28px 8px; }
@media (min-width: 1080px) {
  .toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding-block: 36px; }
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, #f472b6, #a855f7);
  display: grid; place-items: center;
  color: #fff; font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .5px;
}
.brand-text { font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1.1; }
.brand-text small { display: block; font-family: var(--body); font-weight: 500; font-size: 12px; color: var(--ink-faint); }
.toc details { margin-top: 18px; }
.toc summary {
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-soft);
  list-style: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--sheet);
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "▾"; float: right; color: var(--ink-faint); }
@media (min-width: 1080px) {
  .toc summary { display: none; }
}
.toc ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; counter-reset: chap; }
.toc li a {
  display: grid; grid-template-columns: 26px 1fr; align-items: baseline;
  padding: 6px 10px; border-radius: 9px;
  color: var(--ink-soft); text-decoration: none; font-size: 14.5px; line-height: 1.35;
}
.toc li a::before { counter-increment: chap; content: counter(chap, decimal-leading-zero); font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.toc li a.ext::before { counter-increment: none; content: "↗"; font-size: 12px; }
.toc li a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.toc li a.is-current { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.toc-note { margin-top: 18px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }

/* ---------- nội dung ---------- */
main { padding-block: 12px 80px; min-width: 0; }
@media (min-width: 1080px) { main { padding-block: 44px 120px; } }

.masthead { padding-block: 16px 36px; border-bottom: 1px solid var(--line); display: grid; gap: 28px; }
@media (min-width: 860px) { .masthead { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: end; } }
.eyebrow { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
h1 {
  font-family: var(--display); font-weight: 800; font-size: clamp(40px, 6.4vw, 72px);
  line-height: .98; letter-spacing: -.02em; margin: 0; text-wrap: balance;
}
.lede { font-size: 18px; color: var(--ink-soft); max-width: 58ch; margin: 18px 0 0; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.meta-row .pill-cta { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; font-weight: 700; }
.meta-row .pill-cta:hover { filter: brightness(1.08); }
.pill { font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-soft); background: var(--sheet); }

.quickstart { background: var(--sheet); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; box-shadow: var(--shadow); }
.quickstart h2 { font-family: var(--display); font-size: 20px; margin: 0 0 12px; }
.quickstart ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: qs; }
.quickstart li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; font-size: 15px; line-height: 1.45; }
.quickstart li::before { counter-increment: qs; content: counter(qs); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-family: var(--mono); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.sample-note {
  margin: 22px 0 0; display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; color: var(--ink-soft); background: var(--amber-soft); border-radius: 12px; padding: 10px 14px;
}
.sample-note b { color: var(--amber); }

section.chapter { padding-block: 64px 8px; border-bottom: 1px solid var(--line); }
section.chapter:last-of-type { border-bottom: 0; }
.chapter-head { display: grid; gap: 6px; margin-bottom: 30px; max-width: 70ch; }
.chapter-num { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .08em; }
h2 { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 3.6vw, 42px); line-height: 1.05; letter-spacing: -.015em; margin: 0; text-wrap: balance; }
.chapter-head p { margin: 6px 0 0; color: var(--ink-soft); font-size: 17px; }
h3 { font-family: var(--display); font-weight: 600; font-size: 23px; line-height: 1.2; margin: 0 0 10px; text-wrap: balance; }
h4 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }

/* một tính năng = khung máy + phần giải thích */
.feature { display: grid; gap: 22px 40px; padding-block: 26px; }
.feature + .feature { border-top: 1px dashed var(--line); }
@media (min-width: 760px) {
  .feature { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .feature.flip { grid-template-columns: minmax(0, 1fr) auto; }
  .feature.flip .shots { order: 2; }
}
.feature .text { max-width: 64ch; }
.feature .text p { margin: 0 0 10px; }
.feature ol.steps, .feature ul.facts { margin: 8px 0 12px; padding: 0; list-style: none; display: grid; gap: 8px; }
.steps { counter-reset: st; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 6px; }
.steps li::before { counter-increment: st; content: counter(st); font-family: var(--mono); font-weight: 700; font-size: 12.5px; color: var(--accent-ink); background: var(--accent-soft); width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; margin-top: 2px; }
.facts li { position: relative; padding-left: 18px; }
.facts li::before { content: ""; position: absolute; left: 3px; top: .72em; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }
.ui { font-family: var(--mono); font-size: .86em; font-weight: 500; background: var(--accent-soft); color: var(--accent-ink); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.val { font-family: var(--mono); font-size: .9em; font-variant-numeric: tabular-nums; }

.shots { display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 14px; margin: -4px; scroll-snap-type: x proximity; max-width: 100%; }
.shots figure { margin: 0; flex: 0 0 auto; width: 236px; scroll-snap-align: start; }
@media (min-width: 760px) { .shots.one figure { width: 260px; } }
.phone {
  border-radius: 30px; padding: 7px; background: var(--frame); box-shadow: var(--shadow);
  border: 0; width: 100%; cursor: zoom-in; display: block;
}
.phone img { border-radius: 23px; width: 100%; height: auto; aspect-ratio: 390 / 844; object-fit: cover; object-position: top; background: #f3eff8; }
figcaption { font-size: 12.5px; color: var(--ink-faint); line-height: 1.4; margin-top: 8px; padding-inline: 4px; }

.desktop { border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); box-shadow: var(--shadow); background: var(--sheet); cursor: zoom-in; padding: 0; width: 100%; display: block; }
.desktop .bar { display: flex; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--paper); }
.desktop .bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.desk-grid { display: grid; gap: 22px; }
@media (min-width: 900px) { .desk-grid { grid-template-columns: 1fr 1fr; } }
.desk-grid figure { margin: 0; }

.callout { border-radius: 14px; padding: 12px 16px; font-size: 14.5px; line-height: 1.5; margin: 12px 0; }
.callout.clinical { background: var(--alert-soft); color: var(--ink); border-left: 4px solid var(--alert); }
.callout.clinical b { color: var(--alert); }
.callout.tip { background: var(--accent-soft); color: var(--ink); }
.callout.tip b { color: var(--accent-ink); }
.callout.warn { background: var(--amber-soft); color: var(--ink); }
.callout.warn b { color: var(--amber); }

.tier { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.tier.free { background: var(--free-soft); color: var(--free); }
.tier.premium { background: var(--premium-soft); color: var(--premium); }

/* ---------- công cụ ---------- */
.tools { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 8px; }
.tool { background: var(--sheet); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; }
.tool .phone { border-radius: 16px; padding: 4px; }
.tool .phone img { border-radius: 12px; }
.tool h4 { margin: 0 0 4px; font-size: 15.5px; line-height: 1.3; }
.tool p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }
.tool .in { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; line-height: 1.4; }

/* ---------- bảng nhỏ ---------- */
.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
td:first-child { font-weight: 600; white-space: nowrap; }

/* ---------- hỏi đáp ---------- */
.faq { display: grid; gap: 10px; max-width: 76ch; }
.faq details { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 10px 0 2px; color: var(--ink-soft); }

footer { padding-block: 40px 20px; color: var(--ink-faint); font-size: 13px; border-top: 1px solid var(--line); margin-top: 40px; }

/* ---------- xem ảnh lớn ---------- */
dialog.viewer { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1400px); max-height: 94vh; }
dialog.viewer::backdrop { background: rgba(12, 8, 20, .82); }
dialog.viewer img { max-height: 88vh; width: auto; margin: 0 auto; border-radius: 18px; }
dialog.viewer p { color: #efe9f7; text-align: center; font-size: 14px; margin: 10px 0 0; }
dialog.viewer button { position: fixed; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; color: #221b30; font-size: 20px; cursor: pointer; }

/* ---------- Trợ giúp (/tro-giup) ---------- */
.help-search { position: relative; margin-top: 22px; max-width: 640px; }
.help-search input {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--sheet); border: 1.5px solid var(--line-strong); border-radius: 16px;
  padding: 14px 16px 14px 46px; min-height: 54px;
}
.help-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.help-search::before { content: "⌕"; position: absolute; left: 16px; top: 50%; transform: translateY(-52%); font-size: 22px; color: var(--ink-faint); pointer-events: none; }
.help-count { font-size: 13px; color: var(--ink-faint); margin-top: 8px; min-height: 1.4em; }
.help-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.help-chips a { font-size: 13.5px; font-weight: 600; text-decoration: none; color: var(--ink-soft); background: var(--sheet); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.help-chips a:hover { color: var(--accent-ink); border-color: var(--accent); }
.help-group { padding-block: 40px 4px; }
.help-group h2 { font-size: clamp(24px, 3vw, 32px); margin-bottom: 14px; }
.help-group[hidden] { display: none; }
.faq details[hidden] { display: none; }
.faq details { scroll-margin-top: 20px; }
.faq details[open] { border-color: var(--line-strong); box-shadow: var(--shadow); }
.faq summary { list-style: none; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; line-height: 1.4; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); font-size: 18px; color: var(--accent); line-height: 1.2; }
.faq details[open] summary::after { content: "−"; }
.faq .answer { margin-top: 10px; color: var(--ink-soft); }
.faq .answer p { margin: 0 0 8px; }
.faq .answer ol, .faq .answer ul { margin: 6px 0 8px; padding-left: 22px; display: grid; gap: 4px; }
.faq .answer .see { font-size: 14px; font-weight: 600; }
.help-empty { margin-top: 30px; padding: 18px 20px; border-radius: 16px; background: var(--accent-soft); color: var(--ink); }
.help-contact { margin-top: 48px; padding: 22px; border-radius: 18px; background: var(--sheet); border: 1px solid var(--line); display: grid; gap: 10px; max-width: 76ch; }
.help-contact h2 { font-size: 24px; }
.help-contact ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
