/* ---- bundled heading font (Noto Sans Thai), inlined as base64 ---- */
/* ---- design tokens -------------------------------------------------
   Look modeled on learn.chatgpt.com's docs pages: white/near-black
   neutral palette, hairline #ededed borders, gray active pill in the
   left nav, right-hand scroll-spy TOC, generous whitespace. Reading
   face stays Sarabun — the same face the .docx uses — so the web and
   printable versions read as one family of documents; a monospace
   utility face carries structural information (step numbers, chapter
   codes) the way a spec sheet would.
------------------------------------------------------------------- */
:root {
  --bg: #ffffff; --text: #202020; --heading: #0d0d0d; --muted: #5d5d5d;
  --line: #ededed; --pill: #ededed; --hover: #f4f4f4; --chip: #f4f4f4;
  --search-bg: #f4f4f4;
  --note-text: #b42318; --note-bg: #fef3f2; --note-line: #f5d3cf;
  --note-accent: #c2410c;
  --blue: #0169cc;
  --shadow: 0 1px 3px rgba(13,13,13,.06), 0 8px 24px rgba(13,13,13,.06);
}
:root[data-theme="dark"] {
  --bg: #161616; --text: #dfdfdf; --heading: #f4f4f4; --muted: #9f9f9f;
  --line: #2b2b2b; --pill: #303030; --hover: #232323; --chip: #262626;
  --search-bg: #232323;
  --note-text: #ff9a8f; --note-bg: #2a1b19; --note-line: #45211d;
  --note-accent: #f0a58a;
  --blue: #66b5ff;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}
:root {
  --font-body: "Sarabun", "TH Sarabun New", "Noto Sans Thai", "Segoe UI", system-ui, sans-serif;
  --font-title: "Noto Sans Thai", "Sarabun", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body);
  background: var(--bg); color: var(--text);
}
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--heading); outline-offset: 2px;
}
.c-red { color: #d1453b; }
.c-blue { color: #3b7ddd; }

/* ---- topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 60; height: 60px;
  display: flex; align-items: center; gap: 20px; padding: 0 24px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: var(--heading); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
}
.brand .name { font-family: var(--font-title); font-weight: 700; font-size: 15px; color: var(--heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .tag {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.topbar-spacer { flex: 1; }
.search-wrap { position: relative; width: min(340px, 38vw); }
.search-wrap input {
  width: 100%; height: 38px; border: 1px solid transparent; border-radius: 10px;
  background: var(--search-bg); color: var(--text); padding: 0 12px 0 34px;
  font-family: var(--font-body); font-size: 14px;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap .glass {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; pointer-events: none; color: var(--muted);
}
.search-results {
  display: none; position: absolute; top: 44px; left: 0; right: 0; max-height: 60vh;
  overflow-y: auto; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.search-results.open { display: block; }
.search-results a {
  display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none;
}
.search-results a:hover, .search-results a.selected { background: var(--hover); }
.search-results .r-title { font-size: 13.5px; font-weight: 600; color: var(--heading); }
.search-results .r-snippet { font-size: 12.5px; color: var(--muted); margin-top: 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results .r-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.theme-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.theme-btn:hover { background: var(--hover); color: var(--heading); }
.theme-btn svg { width: 17px; height: 17px; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* hamburger — hidden on desktop, shown on mobile (see responsive block) */
.menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--heading); cursor: pointer;
  align-items: center; justify-content: center; flex: 0 0 auto;
}
.menu-btn:hover { background: var(--hover); }
.menu-btn svg { width: 18px; height: 18px; }
.nav-backdrop { display: none; }

/* ---- 3-column layout ---- */
.layout {
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 240px;
  max-width: 1440px; margin: 0 auto; align-items: start;
}
.sidebar {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  padding: 28px 16px 40px 24px;
}
.nav-group-label {
  font-family: var(--font-title);
  font-size: 18px; font-weight: 800; color: var(--heading);
  padding: 0 12px; margin: 0 0 10px; letter-spacing: .2px;
}
/* Number and title side by side, so a title that wraps (Integration) stays
   under itself rather than running back under its number. */
.nav-list .chapter-link { display: flex; gap: 8px; align-items: baseline; }
.ch-num{flex:none;min-width:1.3em;color:var(--muted,#6b7280);font-variant-numeric:tabular-nums;font-weight:600}
.ch-title{min-width:0}
/* Chapter and section numbers come from their place (render.js, data-num),
   never from the stored text, so moving one renumbers the rest. */
.page > h1[data-num]::before,
.page > h2[data-num]::before { content: attr(data-num) " "; }
.toc-panel a[data-num]::before { content: attr(data-num) " "; }
/* When a feature-overview link sits above it, give "สารบัญ" a divider so it's
   clear where the intro ends and the chapter table-of-contents begins. */
.intro-link + .nav-group-label {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.chapter-link {
  display: block; padding: 7px 12px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-family: var(--font-title); font-size: 14px; line-height: 1.45;
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.chapter-link:hover { background: var(--hover); color: var(--heading); }
.chapter-link.active { background: var(--pill); color: var(--heading); font-weight: 600; }
.intro-link { font-weight: 600; margin-bottom: 12px; }

.main-col { min-width: 0; padding: 44px 56px 110px; border-left: 1px solid var(--line); }
.page { display: none; max-width: 800px; }
.page.active { display: block; }
.chapter-eyebrow {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .1em;
  color: var(--muted); text-transform: uppercase; margin: 0 0 14px;
}
.page h1 {
  font-family: var(--font-title);
  font-size: 34px; font-weight: 700; color: var(--heading); letter-spacing: -.01em;
  margin: 0 0 26px; text-wrap: balance; scroll-margin-top: 84px;
}
.page h2 {
  font-family: var(--font-title);
  font-size: 22px; font-weight: 600; color: var(--heading);
  margin: 44px 0 12px; text-wrap: balance; scroll-margin-top: 84px;
}
.page h2:first-of-type { margin-top: 8px; }
.page h4 { font-family: var(--font-title); font-size: 22px; font-weight: 600; color: var(--heading); margin: 40px 0 10px; }
p { line-height: 1.75; margin: 8px 0; font-size: 15.5px; max-width: 84ch; }

/* Step numbers are rendered by a CSS counter, not baked into the HTML, so
   they always reflect the step's real position — adding, deleting, or
   reordering steps (incl. via the inline editor) renumbers automatically and
   can never drift. The counter resets at each subtopic heading (steps restart
   at 1 per "## " section). */
h2 { counter-reset: mstep; }
p.step { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 2px; max-width: none; counter-increment: mstep; }
.step .num {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
  background: var(--chip); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 6px; flex: 0 0 auto; line-height: 1.6;
}
.step .num::before { content: counter(mstep, decimal-leading-zero); }
.step .step-text { max-width: 84ch; }
.step strong, p strong, .step b, p b, h4 b, h4 strong { color: var(--heading); }

p.bullet {
  position: relative; margin: 4px 0 4px 42px; padding-left: 16px; max-width: 80ch;
  color: var(--text);
}
p.bullet::before {
  content: ""; position: absolute; left: 2px; top: .72em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--muted);
}
/* A sub-bullet is still its own flat block (one <p> per block, so saving,
   dragging and deleting work as for any bullet); only its indent and a
   hollow marker set it under the bullet above. */
p.bullet.sub { margin-left: 66px; max-width: 76ch; }
p.bullet.sub::before { background: transparent; border: 1.5px solid var(--muted); width: 6px; height: 6px; box-sizing: border-box; }
p.subgroup {
  margin: 26px 0 6px; font-size: 15.5px; font-weight: 700; color: var(--heading);
}
p.note {
  border-left: 3px solid var(--note-accent);
  padding: 2px 0 2px 18px; margin: 18px 0; max-width: 84ch;
}
.note-label {
  display: block; font-family: var(--font-title); font-weight: 700;
  font-size: 13px; color: var(--note-accent); margin-bottom: 2px;
}
.note-body { color: var(--text); display: block; }
/* A run of notes is one box (render.js marks it): the first is note-open, the
   rest note-cont. Their joins lose the gap so the left rule runs through, and
   only the first shows the label. A box with several notes puts a dot before
   each, so they read as separate points under one heading; a lone note gets
   no dot, or it would look like a list of one. */
p.note.note-open { margin-bottom: 0; padding-bottom: 7px; }
p.note.note-cont { margin-top: 0; padding-top: 0; }
p.note.note-cont > .note-label { display: none; }
p.note.note-open > .note-body,
p.note.note-cont > .note-body { padding-left: 15px; }
p.note.note-open > .note-body::before,
p.note.note-cont > .note-body::before {
  content: "•"; position: absolute; margin-left: -15px;
  color: var(--note-accent); font-weight: 700;
}
/* Bullets inside a note. A note is one <p> and a list cannot live inside a
   paragraph, so each bullet is its own block that follows the note and
   carries on its left rule: together they read as one note. A note whose
   body is left empty shows just its label above the bullets. */
p.bullet.in-note {
  border-left: 3px solid var(--note-accent);
  margin: 0; padding: 3px 0 3px 38px; max-width: 84ch;
}
p.bullet.in-note::before { left: 22px; top: calc(.72em + 3px); }
p.note:has(+ p.in-note) { margin-bottom: 0; padding-bottom: 3px; }
p.in-note:not(:has(+ p.in-note)) { margin-bottom: 18px; padding-bottom: 5px; }
.note-body:empty { display: none; }
body.medit-on .note-body:empty { display: block; min-height: 1.4em; }

/* ---- overview: category cards (--overview-cards) ---- */
.ov-intro{max-width:64ch;margin-bottom:26px}
.ov-intro p{margin:0 0 12px}
.ov-grid{display:flex;flex-direction:column;gap:12px}
.ov-card{border:1px solid var(--line);border-radius:6px;background:var(--bg);overflow:hidden}
.ov-card summary{display:flex;flex-direction:column;gap:10px;padding:15px 16px;cursor:pointer;list-style:none}
.ov-head{display:flex;align-items:center;gap:11px}
.ov-card summary::-webkit-details-marker{display:none}
.ov-ico{width:30px;height:30px;display:grid;place-items:center;border-radius:6px;
  background:var(--chip);font-size:15px;flex:none}
.ov-nm{font-weight:600;font-size:16px;flex:1;line-height:1.35}
.ov-ct{font-size:12px;color:var(--blue);background:var(--chip);
  border-radius:99px;padding:2px 9px;font-variant-numeric:tabular-nums}
body.medit-on .ov-n{display:inline-block;min-width:1ch;padding:0 2px;border-radius:3px;
  box-shadow:inset 0 -1px 0 currentColor}
.ov-chev{width:8px;height:8px;border-right:1.6px solid var(--muted);border-bottom:1.6px solid var(--muted);
  transform:rotate(-45deg);transition:transform .18s ease;flex:none}
.ov-card[open] .ov-chev{transform:rotate(45deg)}
.ov-peek{padding-left:41px;color:var(--muted);font-size:13.5px;display:flex;flex-wrap:wrap;gap:6px}
.ov-peek span{border:1px solid var(--line);border-radius:99px;padding:1px 9px;white-space:nowrap}
.ov-card[open] .ov-peek{display:none}
.ov-body{padding:14px 16px 18px;border-top:1px solid var(--line)}
.ov-body h3{font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);
  margin:16px 0 9px;font-weight:600}
.ov-body ul{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:9px;font-size:15px}
.ov-body ul li{padding-left:15px;position:relative}
.ov-body ul li::before{content:"";position:absolute;left:0;top:.68em;width:6px;height:6px;
  border-radius:99px;background:var(--blue);opacity:.5}
.ov-frow{margin:0;padding:9px 0;border-top:1px solid var(--line)}
.ov-frow .f{display:block}
.ov-frow[data-btype="feat"]{display:block}
.ov-frow[data-btype="feat"] b{display:block;font-weight:600;font-size:15px}
.ov-flist .ov-frow:first-child{border-top:0;padding-top:0}
.ov-flist .f{font-weight:500;font-size:15px}
.ov-flist .d{display:block;color:var(--muted);font-size:13.5px}
@media (max-width:560px){.ov-peek{padding-left:0}}
/* ---- markdown tables (e.g. the feature-overview checklist) ---- */
.table-wrap { margin: 16px 0 22px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.md-table {
  border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14.5px;
}
table.md-table th, table.md-table td {
  border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top;
}
table.md-table thead th {
  background: var(--pill); color: var(--heading); font-family: var(--font-title);
  font-weight: 700; white-space: nowrap; position: sticky; top: 0;
}
table.md-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--pill) 45%, transparent); }
table.md-table td:first-child { color: var(--muted); text-align: right; white-space: nowrap; }
img.shot {
  display: block; max-width: 100%; height: auto; border: 1px solid var(--line);
  border-radius: 12px; margin: 14px 0 24px 42px; box-shadow: var(--shadow);
}

/* IMG_FIT (default on): capped at the column minus the indent, not plain
   100%, or a picture at full width runs 42px past the column's edge. Off for
   manuals that were laid out with that overhang (Bolt). */
body[data-imgfit="1"] img.shot { max-width: calc(100% - 42px); }

/* ---- prev/next footer ---- */
.pager {
  display: flex; justify-content: space-between; gap: 20px;
  border-top: 1px solid var(--line); padding-top: 18px; margin-top: 56px;
}
.pager a {
  display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 48%;
  text-decoration: none; color: inherit;
}
.pager a.next { flex-direction: row-reverse; text-align: right; }
.pager svg { width: 22px; height: 22px; flex: 0 0 auto; color: var(--muted);
  transition: transform .15s ease; }
.pager .dir { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.pager .pg-title {
  display: block; font-family: var(--font-title); font-size: 15.5px; font-weight: 700;
  color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* hover: nudge the arrow outward (prev←, next→); no colour change */
.pager a.prev:hover svg { transform: translateX(-3px); }
.pager a.next:hover svg { transform: translateX(3px); }
.pager .spacer { max-width: 48%; }

/* ---- right "on this page" TOC ---- */
.toc-col {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  padding: 48px 24px 40px 8px; font-size: 13px;
}
.toc-panel { display: none; }
.toc-panel.active { display: block; }
.toc-label { font-family: var(--font-title); font-weight: 700; color: var(--heading); margin: 0 0 8px 14px; font-size: 12.5px; }
.toc-panel a {
  display: block; padding: 5px 0 5px 13px; text-decoration: none; color: var(--muted);
  border-left: 2px solid var(--line); line-height: 1.5; font-family: var(--font-title);
  transition: color .12s ease, border-color .12s ease;
}
.toc-panel a:hover { color: var(--heading); }
.toc-panel a.active { color: var(--heading); border-left-color: var(--heading); font-weight: 600; }

/* ---- responsive ---- */
@media (max-width: 1160px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .toc-col { display: none; }
}
@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 14px; }
  .menu-btn { display: flex; }
  /* search stays on mobile — let it flex/shrink instead of hiding it */
  .topbar-spacer { display: none; }
  .search-wrap { flex: 1 1 auto; width: auto; min-width: 0; max-width: 360px; }
  .layout { display: block; }
  /* สารบัญ becomes an off-canvas drawer toggled by the hamburger */
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; z-index: 70;
    width: min(280px, 82vw); height: auto; padding: 18px 16px 30px;
    background: var(--bg); border-right: 1px solid var(--line); box-shadow: var(--shadow);
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop {
    display: block; position: fixed; inset: 60px 0 0 0; z-index: 65;
    background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .nav-backdrop.open { opacity: 1; pointer-events: auto; }
  .main-col { padding: 26px 20px 70px; border-left: none; }
  img.shot { margin-left: 0; }
  body[data-imgfit="1"] img.shot { max-width: 100%; }
  .brand .tag { display: none; }
}
/* very narrow: drop the brand wordmark so the search keeps a usable width */
@media (max-width: 480px) { .brand .name { display: none; } }

/* ---- lightbox (lightbox.js): click a screenshot to see it full screen ---- */
/* In edit mode a click on a picture is for replacing it, so no zoom cursor. */
body[data-lightbox="1"]:not(.medit-on) img.shot{cursor:zoom-in}
.lb{position:fixed;inset:0;z-index:9999;display:none;place-items:center;
  background:rgba(12,14,18,.92);backdrop-filter:blur(2px)}
.lb.open{display:grid}
.lb img{max-width:min(96vw,1600px);max-height:92vh;object-fit:contain;
  border-radius:10px;box-shadow:0 18px 60px rgba(0,0,0,.5)}
.lb-bar{position:absolute;top:0;left:0;right:0;display:flex;align-items:center;
  justify-content:space-between;gap:12px;padding:14px 64px 14px 18px;color:#e8eaed;
  font-size:13px;line-height:1.4}
.lb-cap{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.9}
.lb-count{flex:none;opacity:.65;font-variant-numeric:tabular-nums}
.lb-btn{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:44px;
  border:0;border-radius:999px;background:rgba(255,255,255,.12);color:#fff;
  font-size:22px;line-height:1;cursor:pointer;display:grid;place-items:center}
.lb-btn:hover{background:rgba(255,255,255,.22)}
.lb-prev{left:16px} .lb-next{right:16px}
.lb-close{position:absolute;top:10px;right:14px;width:38px;height:38px;border:0;
  border-radius:999px;background:rgba(255,255,255,.12);color:#fff;font-size:20px;
  cursor:pointer;display:grid;place-items:center}
@media (max-width:720px){
  .lb-btn{width:38px;height:38px;font-size:19px}
  .lb-prev{left:6px} .lb-next{right:6px}
  .lb img{max-width:96vw;max-height:86vh}
}
