/* Layout: docs-style page — sticky top bar, left table of contents on wide screens
   (collapsible "Mục lục" on phones), one reading column of ~70ch. */
:root {
  --bg: #f4f6f8;          /* cool paper */
  --surface: #ffffff;
  --fg: #141a21;          /* ink */
  --muted: #56606d;
  --line: #d9dee5;
  --accent: #0d6472;      /* teal ink */
  --accent-soft: #e2f0f2;
  --seal: #b4281f;        /* seal red, logo only */
  --req: #a32a22; --req-soft: #fbe9e7;
  --rec: #8a5a00; --rec-soft: #fbf1dc;
  --adv: #2c5aa0; --adv-soft: #e6eef9;
  --ok: #1d7a3a; --ok-soft: #e3f4e8;

  --font-display: "Palatino Linotype", "Book Antiqua", "Iowan Old Style", Palatino, Georgia, serif;
  --font-body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --step--1: 0.875rem; --step-0: 1rem; --step-1: 1.2rem; --step-2: 1.5rem; --step-3: 2.1rem;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1317; --surface: #161c21; --fg: #e6eaee; --muted: #9ba5b0; --line: #2a323a;
    --accent: #5cb8c4; --accent-soft: #15333a; --seal: #e3675d;
    --req: #f08a80; --req-soft: #3a1c1a; --rec: #e6b65a; --rec-soft: #342812;
    --adv: #8ab0ea; --adv-soft: #1b2840; --ok: #6fcf8d; --ok-soft: #15301f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1317; --surface: #161c21; --fg: #e6eaee; --muted: #9ba5b0; --line: #2a323a;
  --accent: #5cb8c4; --accent-soft: #15333a; --seal: #e3675d;
  --req: #f08a80; --req-soft: #3a1c1a; --rec: #e6b65a; --rec-soft: #342812;
  --adv: #8ab0ea; --adv-soft: #1b2840; --ok: #6fcf8d; --ok-soft: #15301f;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--step-0)/1.65 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, summary:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--accent-soft); padding: 0.05em 0.35em; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 16px; top: 8px; z-index: 20; background: var(--surface); padding: 8px 12px; border-radius: 6px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1160px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; }
.seal { width: 30px; height: 30px; flex: none; }
.seal-box { fill: var(--seal); }
.seal-glyph { fill: none; stroke: var(--surface); stroke-width: 2.4; stroke-linecap: square; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.01em; }
.tentam {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.topnav { margin-left: auto; display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: var(--step--1); }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--accent); }
@media (max-width: 640px) { .topnav { display: none; } }

/* ---- shell ---- */
.shell {
  max-width: 1160px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 0 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
main { min-width: 0; max-width: 800px; }
@media (min-width: 1000px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); align-self: start; padding-top: 40px; }
  .toc-box summary { display: none; }
}
.toc-box { margin-top: 16px; }
.toc-box summary {
  cursor: pointer; font-weight: 600; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); list-style: none;
}
.toc-box summary::-webkit-details-marker { display: none; }
.toc-box summary::after { content: "▾"; float: right; color: var(--muted); }
.toc-box[open] summary::after { content: "▴"; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; font-size: var(--step--1); }
.toc a { display: block; padding: 5px 12px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--fg); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---- sections ---- */
section { padding-block: 56px 8px; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
h2 { font-family: var(--font-display); font-size: var(--step-3); line-height: 1.2; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: var(--step-1); line-height: 1.35; margin: 0 0 6px; }
.h3-gap { margin-top: 32px; margin-bottom: 12px; }
.sec-lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 24px; max-width: 65ch; }
p { margin: 0 0 12px; }
.note { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; font-size: var(--step--1); margin-top: 20px; }
.prose p { max-width: 68ch; }

/* ---- hero ---- */
.hero { padding-top: 48px; padding-bottom: 40px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; font-weight: 600; color: var(--accent); margin-bottom: 14px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(1.9rem, 1.2rem + 2.6vw, 2.9rem); line-height: 1.15; margin: 0 0 18px; font-weight: 700; max-width: 22ch; }
.lede { font-size: 1.12rem; max-width: 62ch; margin-bottom: 24px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 8px; font-weight: 600; text-decoration: none; border: 1px solid transparent; }
.btn small { font-weight: 500; font-size: 0.75rem; opacity: 0.85; }
.btn-primary { background: var(--accent); color: var(--surface); }
.btn-ghost { border-color: var(--line); color: var(--fg); background: var(--surface); }
.is-soon { cursor: default; }
.badges { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.badges li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.badges strong { font-size: 1rem; }
.badges span { color: var(--muted); font-size: var(--step--1); }
.proof { display: flex; gap: 10px; align-items: baseline; font-size: var(--step--1); color: var(--muted); max-width: 70ch; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; transform: translateY(-1px); }

/* ---- pain ---- */
.pain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.pain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.pain p { color: var(--muted); margin: 0; font-size: 0.95rem; }

/* ---- 3 steps ---- */
.steps3 { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.steps3 li { counter-increment: s; padding: 18px; border-top: 3px solid var(--accent); background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); min-width: 0; }
.steps3 li::before { content: "Bước " counter(s); display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.steps3 p { color: var(--muted); font-size: 0.95rem; margin: 0; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--line); }
tbody tr:last-child > * { border-bottom: 0; }
thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: var(--bg); }
tbody th { font-weight: 600; }
.spec td:last-child, .policy td:nth-child(4) { color: var(--muted); }
.policy { min-width: 720px; }
.spec { min-width: 560px; }

/* ---- checklist ---- */
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.lv { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.lv-req { color: var(--req); background: var(--req-soft); }
.lv-rec { color: var(--rec); background: var(--rec-soft); }
.lv-adv { color: var(--adv); background: var(--adv-soft); }
.checklist { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.checklist li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .lv { justify-self: start; }
@media (max-width: 480px) { .checklist li { grid-template-columns: 1fr; gap: 6px; } }

/* ---- diagrams ---- */
.diagram { margin: 0 0 28px; }
.diagram-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.diagram svg { display: block; width: 100%; height: auto; }
.seq { min-width: 760px; }
.arch { min-width: 720px; }
figcaption { font-size: var(--step--1); color: var(--muted); margin-top: 8px; }
.diagram text { font-family: var(--font-body); font-size: 13px; fill: var(--fg); text-anchor: middle; }
.diagram text.sub { font-size: 11.5px; fill: var(--muted); }
.lane-head rect { fill: var(--bg); stroke: var(--line); }
.lane-head text { font-weight: 600; }
.lane-head text.sub { font-weight: 400; }
.lane-head rect.lane-key { stroke: var(--accent); stroke-width: 1.5; }
.lifeline line { stroke: var(--line); stroke-dasharray: 4 5; stroke-width: 1.5; }
.act rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.act-key rect { stroke: var(--accent); stroke-width: 2; }
.num circle { fill: var(--accent); }
.num text { fill: var(--surface); font-size: 12px; font-weight: 700; }
.msg { stroke: var(--fg); stroke-width: 1.5; fill: none; }
.msg-back { stroke-dasharray: 6 4; }
.arrow-head { fill: var(--fg); }
.diagram text.lbl { font-size: 12.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.diagram text.lbl-end { font-weight: 600; fill: var(--accent); }
.zone { stroke-width: 1.5; }
.zone-data { fill: var(--accent-soft); stroke: var(--accent); }
.zone-ctrl { fill: var(--bg); stroke: var(--line); }
.zone-ext { fill: var(--surface); stroke: var(--line); stroke-dasharray: 6 4; }
.diagram text.zone-title { text-anchor: start; font-weight: 700; font-size: 13px; }
.diagram text.ext-title { font-weight: 600; }
.node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.node-key rect { stroke: var(--accent); stroke-width: 2; }
.node-relay rect { stroke: var(--fg); stroke-dasharray: 5 4; }
.node text { font-weight: 600; }
.node text.sub { font-weight: 400; }

/* ---- timeline ---- */
.timeline { list-style: none; counter-reset: t; padding: 0; margin: 0; display: grid; gap: 0; }
.timeline li { counter-increment: t; position: relative; padding: 0 0 22px 52px; min-width: 0; }
.timeline li::before {
  content: counter(t); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--surface); font-weight: 700; font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.timeline li::after { content: ""; position: absolute; left: 15px; top: 36px; bottom: 4px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline h3 { padding-top: 3px; }
.timeline p { max-width: 64ch; }
.sees { font-size: var(--step--1); color: var(--muted); border-left: 2px solid var(--accent); padding-left: 10px; }

/* ---- modes ---- */
.mode { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.mode-pin { background: var(--adv-soft); color: var(--adv); }
.mode-del { background: var(--rec-soft); color: var(--rec); }

/* ---- architecture lists ---- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.two-col > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.col-yes h3 { color: var(--fg); }
.col-no { border-color: var(--accent) !important; }
.col-no h3 { color: var(--accent); }
.plain { margin: 0; padding-left: 1.1rem; display: grid; gap: 4px; font-size: 0.95rem; }

/* ---- licenses ---- */
.lic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.lic { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.lic-name { font-family: var(--font-mono); font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.lic p { font-size: 0.95rem; }
.lic-why { color: var(--muted); font-size: var(--step--1) !important; margin: 0; }
.yes, .no { font-weight: 700; }
.yes { color: var(--ok); }
.no { color: var(--req); }
.placeholder { color: var(--muted); font-style: italic; }

/* ---- roadmap ---- */
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.roadmap li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.roadmap li.done { border-color: var(--ok); }
.phase { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.roadmap li.done .phase { color: var(--ok); }
.roadmap li p:last-child { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---- faq ---- */
.faq { display: grid; gap: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.faq summary { cursor: pointer; padding: 13px 0; font-weight: 600; }
.faq details p { color: var(--muted); padding-bottom: 14px; margin: 0; max-width: 68ch; }

/* ---- footer ---- */
.foot { padding-block: 32px 8px; font-size: var(--step--1); color: var(--muted); }
.foot p { margin: 0 0 6px; }
