:root {
  --brand: #8F53F0;
  --brand-ink: #5b32b0;
  --brand-tint: #f3f0fb;
  --ink: #1A1632;
  --muted: #59566B;
  --border: #e5e7eb;
  --surface: #ffffff;
  --surface-2: #faf9fd;
  --accent: #FFAF25;
  --update-tint: #fff8e1;
  --warn: #b45309;
  --warn-tint: #fffbeb;
  --danger: #D62F40;
  --stop-tint: #fef2f2;
  --ok: #1a936f;
  --ok-tint: #ecfdf5;
  --pos-blue: #2f4fd8;
  --pos-tint: #f1f3fb;
  --radius: 14px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-padding-top: 128px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  position: relative;
  min-height: 100vh;
}

@media (min-width: 768px) {
  body {
    font-size: 17px;
  }
}

body::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--brand);
  z-index: 1000;
  pointer-events: none;
}

@media (max-width: 639px) {
  body::before {
    width: 4px;
  }
}

img, video {
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
}

p {
  margin-bottom: 12px;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--brand-ink);
}

:focus-visible {
  outline: 3px solid var(--brand-ink);
  outline-offset: 2px;
}

/* Skip link */
.skip {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 2000;
  padding: 10px 18px;
  background: var(--brand-ink);
  color: #fff;
  border-radius: 9999px;
  font-weight: 700;
  text-decoration: none;
}

.skip:focus, .skip:focus-visible {
  left: 16px;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (min-width: 768px) {
  .site-header .header-inner {
    padding: 12px 24px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.brand img {
  display: block;
  height: 20px;
  width: 112px;
  object-fit: contain;
}

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

.site-header nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 3px solid transparent;
  display: inline-block;
}

.site-header nav a:hover {
  color: var(--brand-ink);
}

.site-header nav a[aria-current="page"] {
  color: var(--brand-ink);
  border-bottom: 3px solid var(--brand);
  font-weight: 700;
}

.site-header form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.site-header .btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: none;
  width: auto;
  min-height: auto;
}

.site-header .btn-link:hover {
  color: var(--danger);
  text-decoration: underline;
}

@media (max-width: 639px) {
  .site-header .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 16px;
  }
  .site-header nav {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
  }
  .site-header nav::-webkit-scrollbar {
    display: none;
  }
}

/* Section Chips */
.chips {
  position: sticky;
  top: 49px;
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 639px) {
  .chips {
    top: 80px;
  }
}

.chips-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .chips-inner {
    padding: 10px 24px;
  }
}

@media (min-width: 1024px) {
  .chips-inner {
    flex-wrap: wrap;
    overflow: visible;
  }
}

.chips-inner::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 9999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.chip b {
  font-weight: 800;
  color: var(--brand-ink);
  margin-right: 6px;
}

.chip:hover {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.chip-manager::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  flex-shrink: 0;
}

/* Main Content Container */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px;
}

@media (min-width: 768px) {
  main {
    padding: 48px 24px;
  }
}

/* Hero Section */
.hero {
  margin-bottom: 32px;
}

.kicker {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--brand-ink);
  font-weight: 700;
  margin-bottom: 8px;
}

.hero h1 {
  font-size: clamp(30px, 7vw, 48px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero h1 .accent {
  color: var(--brand);
  display: block;
}

.rule {
  width: 64px;
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  margin: 16px 0 20px;
}

.lede {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 12px;
}

.meta {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  box-sizing: border-box;
  text-align: center;
}

.btn-primary {
  background: var(--brand-ink);
  color: #fff;
  border-color: var(--brand-ink);
}

.btn-primary:hover {
  background: #4a2790;
  border-color: #4a2790;
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--brand-ink);
  border: 1px solid var(--brand-ink);
}

.btn-secondary:hover {
  background: var(--brand-tint);
  color: var(--brand-ink);
}

/* Lesson Sections */
.lesson {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.lesson-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lesson-header .num {
  font-size: 56px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 639px) {
  .lesson-header .num {
    font-size: 44px;
  }
}

.lesson-meta {
  flex: 1;
  min-width: 220px;
}

.lesson-header h2 {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 4px;
}

.lesson-header .subtitle {
  font-size: 16px;
  color: var(--muted);
  margin: 0;
  font-style: italic;
}

.lesson-bullets {
  margin: 16px 0 20px 24px;
}

.lesson-bullets li {
  margin-bottom: 8px;
}

/* Video */
figure.video {
  margin: 24px 0;
}

figure.video video {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

figure.video figcaption {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

/* Steps */
ol.steps {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

ol.steps > li {
  position: relative;
  padding-left: 48px;
  counter-increment: step-counter;
}

ol.steps > li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
}

ol.steps h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

ol.steps ul {
  margin: 12px 0 12px 20px;
}

ol.steps ul li {
  margin-bottom: 6px;
}

ol.steps.compact {
  gap: 12px;
}

ol.steps.compact > li {
  padding-left: 36px;
}

ol.steps.compact > li::before {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

/* Photos */
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin: 16px 0;
}

figure.shot {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 8px;
  margin: 0;
  display: flex;
  flex-direction: column;
}

figure.shot a {
  display: block;
  text-align: center;
}

figure.shot img {
  max-height: 480px;
  width: 100%;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

figure.shot figcaption {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
  text-align: left;
}

/* POS Message */
blockquote.posmsg {
  background: var(--pos-tint);
  border-left: 4px solid var(--pos-blue);
  border-radius: 0 10px 10px 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  padding: 12px 16px;
  margin: 16px 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  line-height: 1.5;
}

.posmsg .tag {
  display: inline-block;
  background: var(--pos-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 9999px;
  margin-right: 8px;
  vertical-align: middle;
}

/* Callouts */
.callout {
  border-radius: 0 12px 12px 0;
  padding: 12px 16px;
  margin: 20px 0;
  border-left: 4px solid;
}

.callout.note {
  border-left-color: var(--brand);
  background: var(--brand-tint);
}

.callout.warn {
  border-left-color: var(--warn);
  background: var(--warn-tint);
}

.callout.stop {
  border-left-color: var(--danger);
  background: var(--stop-tint);
}

.callout.update {
  border-left-color: var(--accent);
  background: var(--update-tint);
}

.callout .label {
  display: inline-block;
  background: var(--accent);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 10px;
  border-radius: 9999px;
  margin-right: 8px;
  vertical-align: middle;
}

.callout ul {
  margin: 8px 0 8px 20px;
}

.callout ul li {
  margin-bottom: 6px;
}

/* Problem Cases */
.cases {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 24px 0;
}

@media (min-width: 900px) {
  .cases {
    grid-template-columns: 1fr 1fr;
  }
}

article.case {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

article.case h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

article.case.stop {
  border-left: 4px solid var(--danger);
  background: var(--stop-tint);
}

article.case ul {
  margin: 8px 0 8px 20px;
}

article.case ul li {
  margin-bottom: 6px;
}

.more-link {
  margin-top: 20px;
  font-size: 16px;
}

.more-link a {
  color: var(--brand-ink);
  text-decoration: none;
}

.more-link a:hover {
  text-decoration: underline;
}

/* 5 Rules */
ol.rules {
  list-style: none;
  counter-reset: rule-counter;
  padding: 0;
  margin: 24px 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  ol.rules:not(.compact) {
    grid-template-columns: repeat(5, 1fr);
  }
}

ol.rules > li {
  counter-increment: rule-counter;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

ol.rules > li::before {
  content: counter(rule-counter);
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}

ol.rules > li p {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

ol.rules.compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

ol.rules.compact > li {
  flex-direction: row;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: 8px;
  gap: 12px;
}

ol.rules.compact > li::before {
  font-size: 18px;
  width: 24px;
  flex-shrink: 0;
}

/* Tables */
table.matrix {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}

table.matrix th, table.matrix td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

table.matrix thead tr {
  background: var(--brand-tint);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.matrix tr.row-stop {
  border-left: 4px solid var(--danger);
  background: var(--stop-tint);
}

table.matrix .en {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

table.matrix .vi {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 699px) {
  table.matrix thead {
    display: none;
  }
  table.matrix, table.matrix tbody, table.matrix tr, table.matrix td {
    display: block;
    width: 100%;
  }
  table.matrix tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    background: var(--surface);
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  table.matrix tr.row-stop {
    border-left: 4px solid var(--danger);
    background: var(--stop-tint);
  }
  table.matrix td {
    border: none;
    padding: 6px 0;
  }
  table.matrix td:not(:last-child) {
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    padding-bottom: 8px;
  }
  table.matrix td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
  }
  /* The row number only helps in the printed grid; on a phone card it is noise. */
  table.matrix td[data-label="#"] {
    display: none;
  }
}

/* Checklists */
ul.checklist {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

ul.checklist li {
  position: relative;
  padding-left: 30px;
  line-height: 1.5;
}

ul.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--brand-ink);
  border-radius: 4px;
  background: #fff;
  box-sizing: border-box;
}

/* Manager pill */
.pill-danger {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 9999px;
}

/* Login styles & generic forms */
.login {
  margin: 8vh auto;
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.login-logo {
  margin-bottom: 16px;
  display: inline-block;
  height: auto;
}

.login h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.login .lede {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

label {
  display: block;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="email"], input[name="code"] {
  width: 100%;
  font-size: 16px;
  height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  font-family: inherit;
  box-sizing: border-box;
}

button {
  background: var(--brand-ink);
  color: #fff;
  border: none;
  border-radius: 9999px;
  min-height: 44px;
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 20px;
  font-family: inherit;
}

button.btn-secondary {
  background: var(--surface);
  color: var(--brand-ink);
  border: 1px solid var(--brand-ink);
  margin-top: 12px;
}

.form-resend {
  margin-top: 8px;
}

.msg {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.msg-error {
  background: var(--stop-tint);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.msg-ok {
  background: var(--ok-tint);
  color: var(--ok);
  border: 1px solid #bbf7d0;
}

.hint {
  font-size: 14px;
  color: var(--muted);
  text-align: left;
  margin-bottom: 20px;
}

.code-intro {
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.alt-link {
  margin-top: 16px;
  font-size: 14px;
}

.alt-link a, .btn-link {
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

.alt-link a:hover, .btn-link:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 16px;
  margin-top: 64px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin-bottom: 6px;
}

/* Print Styles */
@media print {
  body::before {
    display: none !important;
  }
  .site-header nav, .site-header form, nav.chips, .skip, .actions, figure.video {
    display: none !important;
  }
  @page {
    size: A4;
    margin: 10mm;
  }
  body {
    font-size: 9pt;
    line-height: 1.35;
    background: #fff;
    color: #000;
  }
  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .hero {
    margin-bottom: 8px;
  }
  .hero h1, h1 {
    font-size: 16pt;
    line-height: 1.2;
    margin-bottom: 4px;
  }
  .rule {
    display: none;
  }
  .lede, .meta {
    font-size: 9pt;
    line-height: 1.35;
    margin-bottom: 4px;
  }
  h2 {
    font-size: 11pt;
    margin: 8px 0 4px;
    line-height: 1.2;
  }
  ol.steps {
    margin: 4px 0;
    gap: 2px;
    font-size: 9pt;
  }
  ol.steps > li {
    padding-left: 20px;
    font-size: 9pt;
    line-height: 1.35;
    margin-bottom: 2px;
  }
  ol.steps > li::before {
    width: 14px;
    height: 14px;
    font-size: 7.5pt;
    top: 1px;
  }
  ol.rules {
    display: block;
    margin: 4px 0;
    gap: 0;
  }
  ol.rules > li {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    font-size: 9pt;
    padding: 2px 6px;
    margin: 0 0 2px;
    background: none !important;
    box-shadow: none !important;
    border: none;
  }
  ol.rules > li::before {
    font-size: 9pt;
    width: auto;
    line-height: 1;
  }
  ol.rules > li p {
    font-size: 9pt;
    margin: 0;
  }
  ul.checklist {
    margin: 4px 0;
    gap: 4px;
  }
  table.matrix {
    margin: 6px 0;
    font-size: 8.5pt;
  }
  table.matrix th, table.matrix td {
    padding: 3px 5px !important;
  }
  table.matrix th:first-child,
  table.matrix td[data-label="#"] {
    width: 24px;
    white-space: nowrap;
    text-align: center;
  }
  table.matrix .en {
    font-size: 8.5pt;
    line-height: 1.25;
    margin-bottom: 2px;
  }
  table.matrix .vi {
    font-size: 7.5pt;
    line-height: 1.25;
  }
  table.matrix thead {
    display: table-header-group !important;
  }
  table.matrix tr {
    display: table-row !important;
    border: 1px solid var(--border);
    box-shadow: none !important;
    margin: 0 !important;
    break-inside: avoid;
  }
  table.matrix td {
    display: table-cell !important;
    border: 1px solid var(--border) !important;
  }
  table.matrix td::before {
    display: none !important;
  }
  tr, .callout, .case, li {
    break-inside: avoid;
  }
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .site-header {
    position: static;
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
    margin-bottom: 6px;
  }
  .site-footer {
    margin-top: 10px;
    padding: 6px 0;
    font-size: 8pt;
  }
  .photos {
    gap: 6px;
    margin: 8px 0;
  }
  figure.shot {
    padding: 4px;
  }
  figure.shot img {
    max-height: 200px;
  }
}
