/* Hallmark · macrostructure: Long Document · tone: technical · anchor hue: 262 — tokens ở tokens.css */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  overflow-x: clip;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
}
img {
  max-width: 100%;
  height: auto;
  display: block;
}
a {
  color: var(--color-accent-ink);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--color-accent);
}
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}
code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--color-paper-3);
  border: var(--rule-1);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-style: normal;
  color: var(--color-ink);
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ── Thanh trên ── */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklch, var(--color-paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: var(--rule-1);
}
.top-in {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 56px;
  padding: 0 var(--space-5);
  max-width: 1320px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--color-ink);
  color: var(--color-paper);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.brand small {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.top-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.top-links a {
  white-space: nowrap;
}
.link-quiet {
  color: var(--color-ink-2);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.link-quiet:hover {
  background: var(--color-paper-3);
  color: var(--color-ink);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.btn-primary:hover {
  background: var(--color-accent-ink);
  color: var(--color-on-accent);
}
.btn-primary:active {
  transform: translateY(1px);
}
.btn-ghost {
  border-color: var(--color-rule-strong);
  color: var(--color-ink);
  background: var(--color-paper);
}
.btn-ghost:hover {
  background: var(--color-paper-3);
  color: var(--color-ink);
}

/* ── Khung 2 cột ── */
.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: var(--space-12);
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.toc {
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding: var(--space-8) 0 var(--space-8);
  font-size: var(--text-sm);
}
.toc summary {
  display: none;
}
.toc-group {
  margin-bottom: var(--space-5);
}
.toc-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0 0 var(--space-2);
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: var(--rule-1);
}
.toc a {
  display: block;
  padding: 5px var(--space-3);
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--color-ink-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc a:hover {
  color: var(--color-ink);
}
.toc a.is-current {
  color: var(--color-accent-ink);
  border-left-color: var(--color-accent);
  font-weight: 600;
}

/* ── Nội dung ── */
.doc {
  min-width: 0;
  max-width: 900px;
  padding: var(--space-10) 0 var(--space-20);
}
.hero h1 {
  font-size: var(--text-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
}
.lead {
  font-size: var(--text-lg);
  color: var(--color-ink-2);
  max-width: 64ch;
  margin: 0 0 var(--space-6);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: var(--rule-1);
  border-radius: var(--radius-md);
  background: var(--color-paper);
  margin: 0 0 var(--space-10);
}
.facts > div {
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}
.facts > div + div {
  border-left: var(--rule-1);
}
.facts dt {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}
.facts dd {
  margin: 4px 0 0;
  font-weight: 600;
}

section.chapter {
  padding-top: var(--space-12);
  margin-top: var(--space-12);
  border-top: var(--rule-1);
}
section.chapter > h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}
section.chapter > .intro {
  color: var(--color-ink-2);
  max-width: 68ch;
  margin: 0 0 var(--space-6);
}
h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: var(--space-10) 0 var(--space-3);
}
p,
li {
  max-width: 72ch;
}
.doc ul,
.doc ol.steps {
  padding-left: 1.3em;
}
.doc li + li {
  margin-top: 4px;
}
ol.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0 !important;
}
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  margin-top: var(--space-3);
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-accent-tint);
  color: var(--color-accent-ink);
  font-weight: 700;
  font-size: var(--text-sm);
  display: grid;
  place-items: center;
}

/* Ảnh chụp app: viền mảnh, KHÔNG vẽ lại khung trình duyệt/cửa sổ */
figure.shot {
  margin: var(--space-6) 0 var(--space-8);
}
figure.shot a {
  display: block;
  border: var(--rule-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-paper-3);
  box-shadow: 0 1px 2px var(--color-shadow), 0 8px 24px var(--color-shadow);
}
figure.shot a:hover {
  border-color: var(--color-rule-strong);
}
figure.shot figcaption {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-top: var(--space-3);
  max-width: 72ch;
}
.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}
.pair figure.shot {
  margin: var(--space-4) 0;
}

.note {
  border: var(--rule-1);
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-tint);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
  max-width: 76ch;
}
.note.warn {
  border-left-color: var(--color-warn);
  background: var(--color-warn-tint);
}
.note p {
  margin: 0;
}
.note b:first-child {
  display: block;
  margin-bottom: 2px;
}
.tag-vip {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--color-warn-tint);
  color: var(--color-vip-ink);
  border: 1px solid var(--color-vip-rule);
  vertical-align: middle;
}
.table-wrap {
  overflow-x: auto;
  margin: var(--space-5) 0;
  border: var(--rule-1);
  border-radius: var(--radius-md);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  vertical-align: top;
}
th {
  background: var(--color-paper-2);
  font-weight: 700;
  color: var(--color-ink-2);
  border-bottom: var(--rule-1);
}
tr + tr td {
  border-top: var(--rule-1);
}
details.faq {
  border-bottom: var(--rule-1);
  padding: var(--space-4) 0;
}
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
details.faq summary::-webkit-details-marker {
  display: none;
}
details.faq summary::after {
  content: '+';
  float: right;
  color: var(--color-muted);
  font-weight: 400;
}
details.faq[open] summary::after {
  content: '–';
}
details.faq p {
  margin: var(--space-2) 0 0;
  color: var(--color-ink-2);
}

/* ── Chân trang: liên hệ ── */
.contact {
  margin-top: var(--space-16);
  padding: var(--space-10);
  border-radius: var(--radius-md);
  background: var(--color-ink);
  color: var(--color-paper);
}
.contact h2 {
  color: var(--color-paper);
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-2);
}
.contact p {
  color: var(--color-on-dark-2);
  margin: 0 0 var(--space-6);
}
.contact-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.contact-list a {
  display: block;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-dark-rule);
  color: var(--color-paper);
  text-decoration: none;
  min-width: 0;
}
.contact-list a:hover {
  background: var(--color-dark-2);
}
.contact-list b {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-on-dark-3);
}
.contact-list span {
  font-weight: 600;
  white-space: nowrap;
}
.foot {
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* ── Mobile ── */
@media (max-width: 960px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .toc {
    position: static;
    max-height: none;
    padding: var(--space-4) 0 0;
  }
  .toc summary {
    display: block;
    cursor: pointer;
    font-weight: 600;
    padding: var(--space-3) var(--space-4);
    border: var(--rule-1);
    border-radius: var(--radius-sm);
    background: var(--color-paper-2);
  }
  .toc details:not([open]) .toc-body {
    display: none;
  }
  .toc-body {
    padding: var(--space-4) var(--space-2) 0;
  }
  .doc {
    padding-top: var(--space-6);
  }
}
@media (max-width: 640px) {
  .top-in {
    padding: 0 var(--space-4);
    gap: var(--space-2);
  }
  .brand small,
  .link-quiet.hide-sm {
    display: none;
  }
  .shell {
    padding: 0 var(--space-4);
  }
  .facts {
    grid-template-columns: minmax(0, 1fr);
  }
  .facts > div + div {
    border-left: 0;
    border-top: var(--rule-1);
  }
  .pair,
  .contact-list {
    grid-template-columns: minmax(0, 1fr);
  }
  .contact {
    padding: var(--space-6);
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition-duration: 1ms !important;
  }
}
