:root {
  --plum: #5a2a6b;
  --plum-dark: #3f1c4b;
  --plum-soft: #f3ecf5;
  --ink: #1f1a22;
  --muted: #645b68;
  --line: #e4dde6;
  --bg: #f7f4f1;
  --card: #ffffff;
  --ok: #2f7a4f;
  --err: #b3261e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}
html[data-lang="en"] [data-l="vi"], html[data-lang="vi"] [data-l="en"] { display: none !important; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--plum); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.bname { font-size: 15px; color: var(--muted); }
.bname b { color: var(--ink); font-weight: 600; }
.prog { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.track { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; max-width: 320px; }
.fill { height: 100%; width: 0; background: var(--plum); border-radius: 99px; transition: width .35s ease; }
.lang {
  border: 1px solid var(--plum); background: #fff; color: var(--plum);
  font: inherit; font-size: 14px; font-weight: 600; padding: 6px 14px; border-radius: 99px; cursor: pointer;
}
.lang:hover { background: var(--plum-soft); }

/* Page layout: sticky contents column on the left, guide on the right */
.layout {
  max-width: 1160px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 260px minmax(0, 820px); gap: 40px; justify-content: center;
}
main { min-width: 0; padding: 32px 0 60px; }

.hero { padding: 8px 4px 24px; }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--plum); }
h1 { margin: 0 0 12px; font-size: clamp(26px, 4.5vw, 36px); line-height: 1.2; letter-spacing: -0.01em; }
.lead { margin: 0; color: var(--muted); font-size: 17px; }

/* Contents (vertical menu) */
.side {
  position: sticky; top: 55px; align-self: start;
  max-height: calc(100vh - 55px); overflow-y: auto; overscroll-behavior: contain;
  padding: 32px 4px 24px 0;
}
.side-title { margin: 8px 0 10px 10px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--plum); }
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc a {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 7px 10px; border-radius: 10px; border-left: 3px solid transparent;
  color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.35;
}
.toc a:hover { background: var(--plum-soft); }
.toc a::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
.toc a.is-read::before { background: var(--ok); border-color: var(--ok); }
.toc a.is-current { background: var(--card); border-left-color: var(--plum); color: var(--plum-dark); font-weight: 600; box-shadow: 0 1px 2px rgba(31, 26, 34, .06); }
.toc a.toc-sign { margin-top: 8px; background: var(--plum-soft); font-weight: 600; }
.toc a.toc-sign::before { display: none; }
.toc a.toc-sign.is-current { background: var(--plum); color: #fff; border-left-color: var(--plum-dark); }

/* Contents button: only shown when there is no room for the side column */
.tocbtn {
  display: none; place-items: center; width: 38px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--plum); cursor: pointer;
}
.tocbtn:hover, .tocbtn[aria-expanded="true"] { background: var(--plum-soft); border-color: var(--plum); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1000px) {
  .layout { display: block; max-width: 820px; }
  .tocbtn { display: grid; }
  .side {
    display: none; position: fixed; z-index: 9; top: 55px; left: 0; right: 0;
    max-height: calc(100vh - 55px - 24px); padding: 8px 16px 16px;
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 12px 28px rgba(31, 26, 34, .18);
  }
  .toc-open .side { display: block; }
  .toc a { padding: 10px; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; margin: 0 0 18px;
}
.card h2 { margin: 0 0 14px; font-size: 22px; line-height: 1.3; color: var(--plum-dark); }
.card h3 { margin: 22px 0 6px; font-size: 16.5px; }
.card p { margin: 0 0 12px; }
.card ul, .card ol { margin: 0 0 14px; padding-left: 22px; }
.card li { margin: 0 0 6px; }
.card a { color: var(--plum); text-underline-offset: 2px; }
.note { background: var(--plum-soft); border-radius: 10px; padding: 10px 14px; font-size: 15px; font-style: italic; }

.tablewrap { overflow-x: auto; margin: 4px 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--plum-soft); font-weight: 600; font-size: 14px; }

/* Read checkbox */
.readbox {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  margin-top: 18px; padding: 14px 16px; border-radius: 12px;
  background: var(--bg); border: 1.5px dashed var(--line); font-weight: 500;
}
.readbox input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 6px;
  border: 2px solid var(--muted); background: #fff; display: grid; place-items: center; transition: all .15s;
}
.readbox input:checked + .tick { background: var(--ok); border-color: var(--ok); }
.readbox input:checked + .tick::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.readbox input:focus-visible + .tick { outline: 3px solid var(--plum-soft); outline-offset: 2px; }
.sec.is-read .readbox { border-style: solid; border-color: #bfe0cc; background: #eef7f1; }

/* Sign form */
.signcard { border: 2px solid var(--plum); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.lbl { font-size: 14px; font-weight: 500; color: var(--muted); }
.field input {
  font: inherit; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; min-height: 46px;
}
.field input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px var(--plum-soft); }
.field input.bad { border-color: var(--err); }
.courses { border: 0; padding: 0; margin: 22px 0 0; }
.courses legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.ack { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.sigwrap { margin: 18px 0 6px; }
.siglbl { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
#sig {
  display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
}
.sigbox { position: relative; }
.sigline {
  position: absolute; left: 18px; right: 18px; bottom: 40px; pointer-events: none;
  border-bottom: 1.5px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1;
}
#sig.bad { border-color: var(--err); }
.linkbtn { border: 0; background: none; color: var(--plum); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.hp { position: absolute; left: -9999px; }
.msg { min-height: 1.4em; color: var(--err); font-size: 15px; margin: 10px 0; }
.primary {
  width: 100%; border: 0; border-radius: 12px; padding: 15px 20px; cursor: pointer;
  background: var(--plum); color: #fff; font: inherit; font-size: 17px; font-weight: 600;
}
.primary:hover { background: var(--plum-dark); }
.primary:disabled { opacity: .6; cursor: wait; }
.done { padding: 22px; border-radius: 12px; background: #eef7f1; color: var(--ok); font-weight: 600; font-size: 17px; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding-top: 18px; }

@media (max-width: 640px) {
  .bar { padding: 8px 16px; gap: 10px; }
  .bname { display: none; }
  .prog span { display: none; }
  .layout { padding: 0 16px; }
  main { padding: 20px 0 48px; }
  .side { top: 51px; max-height: calc(100vh - 51px - 24px); }
  .card { padding: 20px 18px; }
  .card h2 { font-size: 20px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  td { border: 0; padding: 3px 0; }
  td::before { content: attr(data-h); display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .fill { transition: none; } }
