/* =====================================================================
   rakaklang.yotathai.com — หน้าแรก (index.html) และหน้า 404 (404.html)
   ชุดออกแบบ "แผ่นงานช่างสำรวจ" ร่วมกับเว็บแอป /app/ (rakaklang-webapp/web/css/app.css)
   ไฟล์นี้ใช้เฉพาะสองหน้านี้ — หน้าอื่น 157 หน้ายังใช้ site.css เดิม ไม่เกี่ยวกัน
   โทเคนสี ฟอนต์ ระยะ มุมโค้ง คัดจาก app.css ตัวต่อตัว (เหตุผลใน design/DESIGN-NOTES.md)
   ฟอนต์ Kanit / Sarabun (SIL Open Font License 1.1) ฝังในโฟลเดอร์ ไม่โหลดจากภายนอก
   ===================================================================== */

@font-face { font-family: "Kanit"; src: url("fonts/kanit-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/kanit-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/kanit-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("fonts/sarabun-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("fonts/sarabun-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --paper: #ffffff;
  --bg: #f3f4f8;
  --bg-grid: rgba(47, 54, 144, .055);
  --ink: #161c2d;
  --ink-2: #444d61;
  --ink-3: #5f6b82;
  --line: #dcdfe8;
  --line-2: #c3c8d6;
  --line-3: #9aa2b5;
  --brand: #2f3690;
  --brand-2: #262c7a;
  --brand-soft: #edeffb;
  --brand-line: #c5c9ef;
  --ok: #1b7a3d;      --ok-soft: #e6f4ea;   --ok-line: #b7dcc3;
  --warn: #8a5300;    --warn-soft: #fff3dc; --warn-line: #efd39a; --warn-mark: #bf7a00;
  --ui: "Kanit", "Sarabun", system-ui, -apple-system, sans-serif;
  --doc: "Sarabun", "TH Sarabun New", "Kanit", system-ui, sans-serif;
  --r: 6px;
  --r2: 10px;
  --maxw: 1180px;
}

/* ---------- พื้นฐาน ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 16px/1.6 var(--ui);
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-2); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: var(--r); z-index: 100; }
.skip:focus { left: 8px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.15em; }
.n { font-family: var(--doc); font-variant-numeric: tabular-nums; }
.nw { white-space: nowrap; }
.tag { display: inline-block; vertical-align: middle; font: 500 12px/1.4 var(--ui); padding: 2px 9px; border: 1px solid var(--line-2); border-radius: 99px; color: var(--ink-2); white-space: nowrap; }

/* ---------- แถบบน ---------- */
.top { position: relative; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 20; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 40px; }
.brand:hover { color: var(--ink); }
.brand img { width: 32px; height: 32px; }
.brand-t b { display: block; font: 600 17px/1.15 var(--ui); }
.brand-t small { display: block; font: 400 12px/1.2 var(--ui); color: var(--ink-3); letter-spacing: .02em; }
.topnav { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 2px 2px; }
.topnav a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 9px; color: var(--ink-2); text-decoration: none; font-size: 14px; border-radius: var(--r); white-space: nowrap; }
.topnav a:hover { color: var(--ink); background: #f1f2f6; }
.topnav a.app { color: var(--brand); border: 1px solid var(--brand-line); background: var(--brand-soft); margin-left: 8px; font-weight: 500; }
.topnav a.app:hover { border-color: var(--brand); color: var(--brand-2); }
.menu-btn { display: none; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--paper); color: var(--ink); font: 500 14px var(--ui); cursor: pointer; }
.menu-btn .ic { width: 18px; height: 18px; }
@media (max-width: 980px) {
  .menu-btn { display: inline-flex; }
  html.js .topnav { display: none; }
  html.js .topnav.open { display: flex; flex-direction: column; align-items: stretch; position: absolute; left: 0; right: 0; top: 100%; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; box-shadow: 0 12px 24px rgba(22, 28, 45, .08); }
  html.js .topnav.open a { min-height: 44px; font-size: 15px; }
  .topnav a.app { margin-left: 0; margin-top: 6px; justify-content: center; }
}

/* ---------- ป้ายประกาศ (ประโยคเดียวกับทุกหน้าของเครื่องมือ) ---------- */
.legal { background: #f7f8fb; border-bottom: 1px solid var(--line); font: 14px/1.45 var(--ui); color: var(--ink-2); padding: 8px 0; }
.legal .wrap { display: flex; gap: 8px; align-items: flex-start; }
.legal .ic { color: var(--brand); width: 16px; height: 16px; margin-top: 3px; }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--paper); color: var(--ink); font: 500 14.5px/1.2 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--line-3); background: #fafbfd; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.big { min-height: 46px; padding: 10px 20px; font-size: 16px; }
.btn .ic { width: 16px; height: 16px; }

/* ---------- หัวหน้า: ชื่อเว็บ + ประตูเข้าเครื่องมือ ---------- */
.mast { padding: 44px 0 36px; }
.mast .wrap { display: grid; grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); gap: 36px 56px; align-items: center; }
.mast-k { font: 14px/1.5 var(--doc); color: var(--ink-3); letter-spacing: .01em; margin-bottom: 14px; }
h1 { font: 500 clamp(28px, 3.3vw, 42px)/1.22 var(--ui); letter-spacing: -.01em; color: var(--ink); max-width: 15em; }
.lead { margin-top: 18px; font-size: 17px; line-height: 1.65; color: var(--ink-2); max-width: 36em; }
.mast-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

.door { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r2); padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.door-h { display: flex; gap: 16px; align-items: flex-start; }
.door-ic { width: 56px; height: 56px; stroke: var(--brand); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; margin-top: 2px; }
.door-h h2 { font: 500 20px/1.25 var(--ui); }
.door-h .tag { margin-left: 6px; }
.door-h small { display: block; color: var(--ink-3); font: 13.5px/1.4 var(--doc); margin-top: 5px; }
.door ul { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.door li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.door li b { font-weight: 500; color: var(--ink); display: block; }
.door-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.door-foot small { color: var(--ink-3); font-size: 13px; line-height: 1.45; }
@media (max-width: 900px) {
  .mast { padding: 32px 0 28px; }
  .mast .wrap { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 560px) {
  .mast-actions .btn { flex: 1 1 100%; }
  .legal { font-size: 13.5px; }
}
@media (max-width: 480px) {
  .door-h { flex-direction: column; gap: 10px; }
  .door-ic { width: 44px; height: 44px; }
}

/* ---------- แถบอ้างอิง (กรอบชื่อแบบ) ---------- */
.ref { margin-top: 8px; }
.ref dl { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r2); overflow: hidden; }
.ref .cell { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.ref .cell:first-child { border-left: 0; }
.ref dt { font: 500 12.5px/1.4 var(--ui); color: var(--ink-3); letter-spacing: .03em; margin-bottom: 4px; }
.ref dd { font: 15px/1.55 var(--doc); color: var(--ink); }
.ref dd b { font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .ref dl { grid-template-columns: 1fr; }
  .ref .cell { border-left: 0; border-top: 1px solid var(--line); }
  .ref .cell:first-child { border-top: 0; }
}

/* ---------- ส่วนเนื้อหา ---------- */
.sec { padding: 52px 0 0; }
.sec-h { max-width: 46em; margin-bottom: 22px; }
.sec-h h2 { font: 500 clamp(22px, 2.2vw, 27px)/1.3 var(--ui); }
.sec-h p { margin-top: 8px; color: var(--ink-2); font-size: 15.5px; }
.panel { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r2); padding: 24px 28px; }
@media (max-width: 700px) {
  .sec { padding-top: 40px; }
  .panel { padding: 18px 16px; }
}

/* ---------- สูตรราคากลาง (สมการตัวใหญ่) ---------- */
.formula { display: grid; grid-template-columns: 1.25fr auto 1fr auto 1fr auto 1.2fr; gap: 0 14px; align-items: start; }
.term { padding: 4px 0; min-width: 0; }
.term .big { display: block; font: 600 clamp(19px, 1.6vw, 24px)/1.25 var(--doc); color: var(--ink); }
.term .cap { display: block; margin-top: 8px; font: 500 13.5px/1.4 var(--ui); color: var(--ink); }
.term .sub { display: block; margin-top: 3px; font: 13px/1.45 var(--ui); color: var(--ink-3); }
.op { font: 400 30px/1 var(--doc); color: var(--ink-3); padding-top: 2px; text-align: center; }
.term.total { border: 1px solid var(--brand-line); background: var(--brand-soft); border-radius: var(--r); padding: 12px 16px; }
.term.total .big { color: var(--brand); }
@media (max-width: 820px) {
  .formula { grid-template-columns: 1fr; gap: 0; }
  .op { text-align: left; padding: 8px 0 4px; font-size: 24px; }
  .term.total { margin-top: 6px; }
}
.box { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 14px; margin: 18px 0 0; font-size: 14px; line-height: 1.55; background: #f9fafc; color: var(--ink-2); }
.box > .ic { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.box.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.box.warn > .ic { color: var(--warn-mark); }
.box b { color: var(--ink); font-weight: 500; }

/* ---------- 6 ขั้นตอน (ไม้บรรทัดวัด) ---------- */
.ruler { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 18px; counter-reset: st; }
.ruler li { position: relative; padding-top: 42px; min-width: 0; }
.ruler li::before { counter-increment: st; content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-3); background: var(--paper); display: grid; place-items: center; font: 600 13px/1 var(--doc); color: var(--ink-2); z-index: 1; }
.ruler li::after { content: ""; position: absolute; left: 28px; right: -18px; top: 14px; border-top: 1px solid var(--line-3); }
.ruler li:last-child::after { display: none; }
.ruler b { display: block; font: 500 15px/1.35 var(--ui); color: var(--ink); }
.ruler p { margin-top: 4px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
@media (max-width: 860px) {
  .ruler { grid-template-columns: 1fr; gap: 18px; }
  .ruler li { padding: 0 0 0 44px; min-height: 28px; }
  .ruler li::after { left: 14px; right: auto; top: 28px; bottom: -18px; border-top: 0; border-left: 1px solid var(--line-3); }
}

/* ---------- สารบัญ (สมุดบัญชี) ---------- */
.toc { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(6, auto); gap: 0 48px; }
.toc li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 0 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toc li:nth-last-child(-n+2) { border-bottom: 0; }
.toc .no { font: 600 13px/1.9 var(--doc); color: var(--ink-3); letter-spacing: .03em; }
.toc .ttl { font: 500 16.5px/1.35 var(--ui); color: var(--ink); text-decoration: none; }
.toc .ttl:hover { color: var(--brand); text-decoration: underline; }
.toc p { margin-top: 3px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.toc .more { margin-top: 6px; font-size: 13.5px; color: var(--ink-3); line-height: 1.7; }
.toc .more a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line-2); padding-bottom: 1px; }
.toc .more a:hover { color: var(--brand); border-color: var(--brand); }
.toc .more .ic { width: 12px; height: 12px; vertical-align: -1px; margin-left: 1px; color: var(--ink-3); }
.toc .cnt { text-align: right; font: 600 15px/1.3 var(--doc); color: var(--ink); white-space: nowrap; padding-top: 3px; font-variant-numeric: tabular-nums; }
.toc .cnt small { display: block; font: 400 12px/1.3 var(--ui); color: var(--ink-3); }
@media (max-width: 860px) {
  .toc { grid-template-columns: 1fr; grid-auto-flow: row; grid-template-rows: none; }
  .toc li:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .toc li:last-child { border-bottom: 0; }
}

/* ---------- ไทม์ไลน์ (ตลับเมตร) ---------- */
.tape { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 18px; }
.tape li { position: relative; padding-top: 22px; min-width: 0; }
.tape li::before { content: ""; position: absolute; left: 0; right: -18px; top: 0; border-top: 1px solid var(--line-3); }
.tape li:last-child::before { right: 0; }
.tape li::after { content: ""; position: absolute; left: 0; top: 0; width: 1px; height: 12px; background: var(--ink-2); }
.tape .d { display: block; font: 600 15px/1.3 var(--doc); color: var(--brand); font-variant-numeric: tabular-nums; }
.tape b { display: block; margin-top: 4px; font: 500 15px/1.35 var(--ui); }
.tape p { margin-top: 3px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
@media (max-width: 860px) {
  .tape { grid-template-columns: 1fr; gap: 16px; }
  .tape li { padding: 0 0 0 22px; }
  .tape li::before { left: 0; right: auto; top: 0; bottom: -16px; border-top: 0; border-left: 1px solid var(--line-3); }
  .tape li:last-child::before { bottom: 0; }
  .tape li::after { width: 12px; height: 1px; left: 0; top: 11px; }
}

/* ---------- ป้ายอบรมโยธาไทยเทรนนิ่ง (โครงจาก promo.js เดิม — จัดรูปใหม่ให้เข้าชุด) ---------- */
[data-promo] { margin-top: 56px; }
.train-promo { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r2); padding: 24px 28px; }
.tp-head { max-width: 46em; }
.tp-badge { display: inline-block; font: 500 12.5px/1.6 var(--ui); color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 99px; padding: 1px 10px; margin-bottom: 10px; }
.train-promo h3 { font: 500 21px/1.3 var(--ui); color: var(--ink); }
.tp-head p { margin-top: 6px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.tp-courses { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.tp-course { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); transition: border-color .15s, background .15s; }
.tp-course:hover { border-color: var(--line-3); background: #fafbfd; color: var(--ink); }
.tp-c-name { font: 500 15px/1.45 var(--ui); }
.tp-c-note { font: 13px/1.45 var(--ui); color: var(--ink-3); }
.tp-tag { display: inline-block; vertical-align: middle; font: 500 11.5px/1.5 var(--ui); color: var(--ok); background: var(--ok-soft); border: 1px solid var(--ok-line); border-radius: 99px; padding: 0 7px; margin-left: 4px; }
.tp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.tp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--brand); border-radius: var(--r); background: var(--brand); color: #fff; font: 500 14.5px/1.2 var(--ui); text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.tp-btn:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.tp-btn.ghost { background: var(--paper); border-color: var(--line-2); color: var(--ink); }
.tp-btn.ghost:hover { border-color: var(--line-3); background: #fafbfd; color: var(--ink); }
.tp-line { font-size: 13.5px; color: var(--ink-2); margin-left: auto; }
.tp-line b { font-weight: 500; color: var(--ink); }
@media (max-width: 720px) {
  .tp-courses { grid-template-columns: 1fr; }
  .train-promo { padding: 20px 16px; }
  .tp-line { margin-left: 0; width: 100%; }
}

/* ---------- ท้ายเว็บ ---------- */
.foot { margin-top: 56px; border-top: 1px solid var(--line-2); background: var(--paper); padding: 36px 0 26px; font-size: 14px; }
.foot-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 28px; }
.foot-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font: 600 15px var(--ui); color: var(--ink); }
.foot-brand img { width: 28px; height: 28px; }
.foot-note { color: var(--ink-3); font-size: 13.5px; line-height: 1.6; max-width: 36em; }
.foot h3 { font: 500 14px/1.3 var(--ui); color: var(--ink); margin: 0 0 6px; }
.foot ul { list-style: none; padding: 0; }
.foot li a { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; }
.foot li a:hover { color: var(--brand); text-decoration: underline; }
.foot li .ic { width: 12px; height: 12px; color: var(--ink-3); }
.foot-bottom { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font: 13px/1.5 var(--doc); color: var(--ink-3); }
@media (max-width: 760px) {
  .foot { margin-top: 44px; }
  .foot-grid { grid-template-columns: 1fr; gap: 20px; }
}

/* ---------- หน้า 404 ---------- */
.err { padding: 48px 0 0; }
.err .panel { max-width: 680px; }
.err-code { font: 600 56px/1 var(--doc); color: var(--ink-3); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.err h1 { font: 500 26px/1.3 var(--ui); margin-top: 8px; max-width: none; }
.err .path { margin-top: 14px; font: 14px/1.5 var(--doc); color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 10px; background: #f9fafc; word-break: break-all; }
.err .path span { color: var(--ink); font-weight: 600; }
.err p { margin-top: 14px; color: var(--ink-2); }
.err .acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.err .more { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); line-height: 1.9; }
.err .more a { color: var(--ink-2); }
.err .more a:hover { color: var(--brand); }
@media (max-width: 700px) {
  .err { padding-top: 32px; }
  .err .acts .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  body { background: #fff; }
  .menu-btn, .topnav, [data-promo], .skip { display: none !important; }
  .panel, .door, .ref dl { border-color: #999; }
}
