:root {
  color-scheme: light;
  --bg: #f5f8f6;
  --surface: #ffffff;
  --text: #15201a;
  --muted: #5a6761;
  --line: #e1e8e4;
  --brand: #00c853;
  --accent: #00873c;
  --on-accent: #ffffff;
  --accent-soft: #e5f6ec;
  --hero-top: #e3f7ea;
  --shadow: 0 1px 2px rgba(16, 40, 26, 0.04), 0 10px 30px rgba(16, 40, 26, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1311;
    --surface: #151b18;
    --text: #e4ebe7;
    --muted: #9ba8a1;
    --line: #25302a;
    --accent: #5fd68e;
    --on-accent: #0b1a11;
    --accent-soft: rgba(95, 214, 142, 0.12);
    --hero-top: #11261a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

strong { font-weight: 600; }

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

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.pages {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.pages a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.pages a:hover { color: var(--text); background: var(--accent-soft); }
.pages a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.lang-switch {
  display: inline-flex;
  flex: none;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.lang-switch a {
  padding: 3px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.lang-switch a[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

@media (max-width: 599px) {
  .pages { display: none; }
  .lang-switch { margin-left: auto; }
}

/* Hero */

.hero {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--hero-top), var(--bg));
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.0625rem;
}

.updated {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 0;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.updated::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

/* Document layout */

.layout {
  display: grid;
  gap: 24px;
  padding-top: 32px;
  padding-bottom: 72px;
}

.toc {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px 16px;
}

.toc summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  list-style: none;
}

.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: " ▾"; }
.toc[open] summary::after { content: " ▴"; }

.toc ol {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.toc li { counter-increment: toc; }

.toc a {
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  text-decoration: none;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

.toc a:hover { color: var(--text); background: var(--accent-soft); }
.toc a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

@media (min-width: 960px) {
  .layout {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 48px;
  }

  .toc {
    position: sticky;
    top: 88px;
    align-self: start;
    max-height: calc(100vh - 112px);
    overflow: auto;
    padding: 0;
    border: 0;
    background: none;
  }

  .toc summary { pointer-events: none; padding-left: 10px; }
  .toc summary::after { content: none; }
}

.content { min-width: 0; }

.paper {
  padding: 4px 40px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  counter-reset: sec;
}

.paper section {
  padding: 32px 0;
  border-top: 1px solid var(--line);
}

.paper section:first-child { border-top: 0; }

.paper h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 1.25rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  scroll-margin-top: 88px;
  counter-increment: sec;
}

.paper h2::before {
  content: counter(sec, decimal-leading-zero);
  flex: none;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transform: translateY(-2px);
}

.paper p { margin: 0 0 12px; }
.paper p:last-child { margin-bottom: 0; }

.paper ul {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.paper ul:last-child { margin-bottom: 0; }

.paper li {
  position: relative;
  margin: 10px 0;
  padding-left: 22px;
}

.paper li::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

@media (max-width: 599px) {
  .paper { padding: 0 20px; border-radius: 16px; }
  .paper section { padding: 24px 0; }
  .hero { padding: 40px 0 32px; }
}

/* Highlights */

.glance {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.glance > div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.icon {
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  fill: var(--accent);
}

.glance h3 {
  margin: 12px 0 4px;
  font-size: 1rem;
  line-height: 1.4;
}

.glance p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.callout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--accent-soft);
}

.callout .icon { flex: none; background: var(--surface); }
.callout p { margin: 0; }

.mail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}

.mail svg { width: 18px; height: 18px; fill: currentColor; }

/* Home */

.hero-home { padding: 72px 0 56px; text-align: center; }
.hero-home .lede { margin-left: auto; margin-right: auto; }

.app-icon {
  width: 96px;
  height: 96px;
  margin-bottom: 20px;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
  padding-top: 32px;
  padding-bottom: 72px;
}

.link-card {
  display: block;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.link-card h2 {
  margin: 14px 0 4px;
  font-size: 1.125rem;
}

.link-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Footer */

.site-footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.site-footer .brand { font-size: 1rem; }
.site-footer .brand img { width: 24px; height: 24px; border-radius: 7px; }
.copy { margin: 0 0 0 auto; }

/* #en / #vi links scroll to the article; keep its hero below the header. */
.doc { scroll-margin-top: 64px; }

/* Without JavaScript both languages stay visible, one after the other. */
.doc + .doc { border-top: 1px solid var(--line); }
