/* ==========================================================================
   form.css — หน้าฟอร์ม / ประวัติของฉัน (ใช้ร่วมกับ main.css)
   ========================================================================== */

body.fm { background: var(--fm-bg, #fff); }   /* พื้นขาวเหมือนหน้าอื่น (ฟอร์มที่ตั้งสีธีมไว้ยังใช้สีของฟอร์มนั้น) */
/* ดัน footer ลงไปชิดล่างจอเสมอ (หน้าที่เนื้อหาสั้น footer จะไม่ลอยอยู่กลางจอ) · padding-bottom เว้นที่ให้แถบเมนูล่างจาก main.css */
body.fm { display: flex; flex-direction: column; min-height: 100dvh; }
.fm .fm-main { flex: 1 0 auto; width: 100%; min-height: 0; margin-inline: auto; }
.fm .fm-main { padding-bottom: var(--s7, 2.5rem); }                       /* เว้นระยะใต้เนื้อหา ไม่ให้ข้อความท้ายฟอร์มชิดเส้นขอบ footer */
.fm .site-foot { margin-top: auto; padding-top: var(--s6); padding-bottom: var(--s5); }
.fm .site-foot .wrap { padding-bottom: var(--s2); }

/* แถบเมนู ฟอร์ม / ประวัติของฉัน: ใช้ .tabs / .tab ชุดเดียวกับหน้าคิวกดบัตร-คิวผ่อนบัตร (อยู่ล่างจอบนมือถือ, ขึ้นหัวเว็บที่จอ ≥900px) แค่มี 2 ปุ่ม */
.fm .tabs { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .fm .tabs { grid-template-columns: none; } }
body.fm-themed .tab[aria-current="page"] { background: var(--fm-accent); color: #fff; }

.fm-who { grid-area: who; position: relative; justify-self: end; min-width: 44px; min-height: 46px; display: flex; align-items: center; justify-content: flex-end; font-size: var(--fs-sm); font-weight: 600; }
.fm-who img, .fm-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; object-fit: cover; background: var(--soft-2); }
.fm-me { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; max-width: 100%; padding: 4px 6px 4px 4px; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; cursor: pointer; transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.fm-me:active { transform: scale(.96); }
.fm-me[aria-expanded="true"] { background: var(--soft); }
.fm-me-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-me-chev { width: 16px; height: 16px; flex: none; color: var(--ink-3); transition: transform var(--dur) var(--ease); }
.fm-me[aria-expanded="true"] .fm-me-chev { transform: rotate(180deg); }
@media (max-width: 479px) { .fm-me-name { display: none; } .fm-me { padding-right: 8px; } }
@media (hover: hover) { .fm-me:hover { border-color: var(--ink-3); } }
.fm-login { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 var(--s4); border: 0; border-radius: 999px; background: #06c755; color: #fff; font: inherit; font-weight: 700; white-space: nowrap; cursor: pointer; transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.fm-login svg { width: 20px; height: 20px; flex: none; }
.fm-login:active { transform: scale(.96); }
.fm-login:disabled { opacity: .6; pointer-events: none; }
@media (hover: hover) { .fm-login:hover { filter: brightness(.94); } }
@media (max-width: 359px) { .fm-login span { display: none; } .fm-login { width: 44px; padding: 0; } }
.fm-static { display: inline-flex; align-items: center; gap: var(--s2); }
@media (max-width: 479px) { .fm-static .fm-me-name { display: none; } }
.fm-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: min(260px, calc(100vw - 2rem)); padding: var(--s2); background: #fff; border: 1px solid var(--line); border-radius: var(--r-field); box-shadow: 0 16px 48px rgba(0, 0, 0, .18); transform-origin: top right; animation: fm-pop .16s var(--ease) both; }
.fm-menu[hidden] { display: none; }
.fm-who[hidden] { display: flex !important; visibility: hidden; }   /* ยังไม่รู้สถานะล็อกอิน: กันที่ไว้ ไม่ให้หัวหน้าเว็บกระโดด */
.fm-menu-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s2); }
.fm-menu-head img, .fm-menu-head .fm-avatar { width: 44px; height: 44px; }
.fm-menu-head div { min-width: 0; }
.fm-menu-head b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-menu-head small { display: block; color: var(--ink-3); font-weight: 500; }
.fm-menu-out { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 46px; padding: 0 var(--s3); border: 0; border-radius: var(--r-tile); background: none; color: var(--red-ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.fm-menu-out:active { background: var(--red-tint); }
@media (hover: hover) { .fm-menu-out:hover { background: var(--red-tint); } }
@keyframes fm-pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }

.fm-main { padding-top: var(--s4); max-width: 720px; min-height: 60dvh; }

.fm-loading { display: flex; align-items: center; justify-content: center; gap: var(--s3); padding: var(--s7) 0; color: var(--ink-3); }
.fm-spin { width: 20px; height: 20px; border: 3px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: fm-rot .8s linear infinite; }
@keyframes fm-rot { to { transform: rotate(360deg); } }

/* ── Cards ────────────────────────────────────────────────────────────── */
.fm-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s4); margin-bottom: var(--s3); }
.fm-card h1, .fm-card h2 { font-size: var(--fs-lg); font-weight: 700; }
.fm-head { padding: var(--s5) var(--s4) var(--s4); border-top: 8px solid var(--brand); }
.fm-head h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.fm-head p { margin-top: var(--s2); color: var(--ink-2); }
.fm-step { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); }
.fm-bar { height: 6px; margin-bottom: var(--s3); border-radius: 999px; background: var(--soft-2); overflow: hidden; }
.fm-bar i { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .3s var(--ease); }

/* ── Rich text (fmt) ──────────────────────────────────────────────────── */
.fm-rich { color: var(--ink); line-height: 1.75; overflow-wrap: anywhere; }
.fm-rich h4 { margin: var(--s4) 0 var(--s2); font-size: var(--fs-md); font-weight: 700; text-decoration: underline; text-underline-offset: .25em; }
.fm-rich h4:first-child { margin-top: 0; }
.fm-rich ul { list-style: disc; padding-left: 1.25rem; display: grid; gap: var(--s2); }
.fm-rich p + p, .fm-rich p + ul, .fm-rich ul + p { margin-top: var(--s2); }
.fm-rich b { font-weight: 700; }

/* ── Questions ────────────────────────────────────────────────────────── */
.fm-q { border: 1px solid var(--line); border-radius: var(--r-card); background: #fff; box-shadow: var(--shadow); padding: var(--s4); margin: 0 0 var(--s3); min-width: 0; }
.fm-q.has-err { border-color: var(--red); }
.fm-q legend, .fm-q > .fm-label { float: left; width: 100%; padding: 0; margin-bottom: var(--s2); font-size: var(--fs-md); font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.fm-q legend + *, .fm-q > .fm-label + * { clear: both; }
.fm-req { margin-left: 2px; color: var(--red); font-weight: 700; }
.fm-desc { margin-bottom: var(--s3); color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.7; }
.fm-err { display: none; margin-top: var(--s2); color: var(--red-ink); font-size: var(--fs-sm); font-weight: 600; }
.has-err .fm-err { display: block; }

.fm-in, .fm-ta, .fm-sel {
  width: 100%; min-height: 48px; padding: 0 var(--s3); font-family: inherit; font-size: 1rem; /* 16px: กัน iOS ซูมเข้าตอนแตะช่องกรอก */ color: var(--ink);
  background: var(--soft); border: 2px solid transparent; border-radius: var(--r-field); outline: 0;
  transition: background-color var(--dur), border-color var(--dur);
}
.fm-ta { min-height: 110px; padding: var(--s3); line-height: 1.6; resize: vertical; }
.fm-in:focus, .fm-ta:focus, .fm-sel:focus { background: #fff; border-color: var(--brand); }
.fm-in::placeholder, .fm-ta::placeholder { color: var(--ink-3); opacity: .6; }

.fm-opts { display: grid; gap: var(--s1); }
.fm-opt { position: relative; display: flex; align-items: flex-start; gap: var(--s3); min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-tile); cursor: pointer; line-height: 1.55; overflow-wrap: anywhere; transition: background-color var(--dur); }
@media (hover: hover) { .fm-opt:hover { background: var(--soft); } }
.fm-opt input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); }
.fm-opt:has(input:checked) { background: var(--brand-tint); }
.fm-opt:has(input:focus-visible) { outline: 3px solid var(--brand-text); outline-offset: 1px; }

.fm-file { display: grid; gap: var(--s3); }
.fm-pick { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 52px; padding: 0 var(--s4); border: 1.5px dashed var(--line-2); border-radius: var(--r-field); background: #fff; font-weight: 600; cursor: pointer; }
@media (hover: hover) { .fm-pick:hover { border-color: var(--brand); } }
.fm-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fm-pick:has(input:focus-visible) { outline: 3px solid var(--brand-text); outline-offset: 2px; }
.fm-thumb { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border: 1px solid var(--line); border-radius: var(--r-tile); }
.fm-thumb img { width: 64px; height: 64px; flex: none; border-radius: 10px; object-fit: cover; background: var(--soft); }
.fm-thumb span { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.fm-link { border: 0; background: none; padding: var(--s2); color: var(--red-ink); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; text-decoration: underline; }

/* ── Buttons / nav row ────────────────────────────────────────────────── */
/* ── ช่องเซ็นลายเซ็น (สัญญา) ───────────────────────────────────────────── */
.fm-sig { position: relative; margin-top: var(--s3); border: 2px dashed var(--line-2); border-radius: var(--r-field); background: var(--soft); overflow: hidden; transition: border-color var(--dur), background-color var(--dur); }
.fm-sig canvas { display: block; width: 100%; aspect-ratio: 5 / 2; touch-action: none; cursor: crosshair; }
.fm-sig canvas.is-locked { cursor: default; }
.fm-sig-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: var(--fs-md); pointer-events: none; }
.fm-sig-ph[hidden] { display: none; }
.fm-sig.is-ok { border-style: solid; border-color: var(--green-ink); background: #fff; }
.fm-sig-acts { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.fm-sig-acts .btn { flex: 1 1 10rem; min-height: 52px; }
.fm-sig-acts .btn:disabled { opacity: 1; background: var(--green-tint); color: var(--green-ink); border-color: var(--green-tint); cursor: default; }
.fm-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.fm-actions .btn { flex: 1; }
.fm-actions .btn-ghost { flex: 0 0 auto; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.fm-note { margin-top: var(--s3); text-align: center; font-size: var(--fs-sm); color: var(--ink-3); }
.fm-fail { margin-top: var(--s3); padding: var(--s3); border-radius: var(--r-tile); background: var(--red-tint); color: var(--red-ink); font-weight: 600; font-size: var(--fs-sm); }

/* ── Gate / states ────────────────────────────────────────────────────── */
.fm-gate { text-align: center; padding: var(--s6) var(--s4); }
.fm-gate h1 { font-size: var(--fs-lg); }
.fm-gate p { margin: var(--s2) auto var(--s4); max-width: 34ch; color: var(--ink-2); }
.fm-line-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 52px; padding: 0 var(--s5); border: 0; border-radius: 999px; background: #06c755; color: #fff; font-weight: 700; font-size: var(--fs-md); cursor: pointer; text-decoration: none; }
.fm-line-btn:active { transform: scale(.97); }
.fm-ok { text-align: center; padding: var(--s6) var(--s4); }
.fm-ok-ico { width: 64px; height: 64px; margin: 0 auto var(--s3); display: grid; place-items: center; border-radius: 50%; background: var(--green-tint); color: var(--green-ink); }
.fm-ok-ico svg { width: clamp(28px, 24px + 1vw, 36px); height: clamp(28px, 24px + 1vw, 36px); fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fm-ok h1 { font-size: 1.25rem; }
.fm-ok p { margin: var(--s2) auto var(--s4); max-width: 38ch; color: var(--ink-2); }
.fm-ok .fm-actions { justify-content: center; flex-wrap: wrap; }

/* ── Form list ────────────────────────────────────────────────────────── */
.fm-list { display: grid; gap: var(--s3); }
.fm-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); }
.fm-item:active { transform: scale(.985); }
.fm-item b { display: block; font-size: var(--fs-md); overflow-wrap: anywhere; }
.fm-item small { display: block; margin-top: 2px; color: var(--ink-3); font-size: var(--fs-sm); }
.fm-item > div { flex: 1; min-width: 0; }

/* ── History ──────────────────────────────────────────────────────────── */
.fm-prof { display: flex; align-items: center; gap: var(--s3); }
.fm-prof .fm-avatar { width: 52px; height: 52px; }
.fm-prof b { display: block; font-size: var(--fs-lg); }
.fm-prof span { color: var(--ink-3); font-size: var(--fs-sm); }
.fm-h { padding: 0; overflow: hidden; }
.fm-h summary { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); cursor: pointer; list-style: none; }
.fm-h summary::-webkit-details-marker { display: none; }
.fm-h summary > div { flex: 1; min-width: 0; }
.fm-h summary b { display: block; overflow-wrap: anywhere; }
.fm-h summary small { color: var(--ink-3); font-size: var(--fs-sm); }
.fm-h[open] summary { border-bottom: 1px solid var(--line); }
.fm-h dl { display: grid; gap: var(--s3); padding: var(--s4); }
.fm-h dt { font-size: var(--fs-sm); color: var(--ink-3); }
.fm-h dd { margin-top: 2px; white-space: pre-line; overflow-wrap: anywhere; }
.fm-st { display: inline-flex; padding: 1px 11px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.fm-st.new { background: var(--amber-tint); color: var(--amber-ink); }
.fm-st.in_progress { background: #e4efff; color: #1b4f9c; }
.fm-st.done { background: var(--green-tint); color: var(--green-ink); }
.fm-st.late { background: var(--red-tint); color: var(--red-ink); }

/* ── ประวัติการผ่อน ───────────────────────────────────────────────────── */
.fm-prog { height: 10px; border-radius: 999px; background: var(--soft-2); overflow: hidden; }
.fm-prog i { display: block; height: 100%; border-radius: 999px; background: #2fb457; }
.fm-ct-line { color: var(--ink-2); font-size: var(--fs-sm); }
.fm-empty { text-align: center; padding: var(--s6) var(--s4); color: var(--ink-3); }

/* ── แนบสลิป ───────────────────────────────────────────────────────────── */
.fm-slip-btn { width: 100%; margin-top: var(--s2); }
.fm-slip-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.fm-slip-row > div { min-width: 0; }
.fm-slip-why { margin-top: 4px; padding: var(--s2) var(--s3); border-radius: 10px; background: var(--red-tint); color: var(--red-ink); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.fm-slip-box { text-align: left; justify-items: stretch; max-height: calc(100dvh - 2rem); overflow-y: auto; }
.fm-slip-box h2 { text-align: center; }
.fm-slip-for { display: grid; padding: 0 var(--s4); background: var(--soft); border-radius: 16px; }
.fm-slip-for > div { min-width: 0; padding: var(--s3) 0; }
.fm-slip-for small { display: block; color: var(--ink-3); font-size: var(--fs-sm); }
.fm-slip-for b { display: block; font-size: var(--fs-md); line-height: 1.4; }
.fm-slip-for .t b { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.fm-slip-for .r { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); border-top: 1px solid var(--line-2); }
.fm-slip-for .r small { color: var(--ink-2); }
.fm-slip-for .r b { color: var(--red-ink); font-size: var(--fs-lg); white-space: nowrap; }
.fm-drop { position: relative; display: grid; justify-items: center; gap: 4px; padding: var(--s5) var(--s4); border: 2px dashed var(--line-2); border-radius: 18px; background: #fff; text-align: center; cursor: pointer; transition: border-color .18s, background-color .18s; }
.fm-drop svg { color: var(--ink-3); margin-bottom: 4px; }
.fm-drop b { font-size: var(--fs-md); font-weight: 700; }
.fm-drop small { color: var(--ink-3); font-size: var(--fs-sm); }
.fm-drop:active { background: var(--soft); }
.fm-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fm-drop:has(input:focus-visible) { outline: 3px solid var(--brand-text); outline-offset: 2px; }
@media (hover: hover) { .fm-drop:hover { border-color: var(--brand); } }
.fm-prev { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--soft); }
.fm-prev img { display: block; width: 100%; max-height: min(42dvh, 320px); object-fit: contain; background: var(--soft); }
.fm-prev-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s1) var(--s3); background: #fff; border-top: 1px solid var(--line); }
.fm-prev-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: var(--fs-sm); }
.fm-prev-bar .fm-link { flex: none; text-decoration: none; color: var(--brand-text); }
.fm-slip-box .btn { min-height: 52px; }
.fm-slip-f { display: grid; gap: 6px; font-weight: 600; font-size: var(--fs-base); }
.fm-slip-f small { font-weight: 400; color: var(--ink-3); }
.fm-slip-box .fm-pick { width: 100%; }
.fm-toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); z-index: 60; transform: translateX(-50%); max-width: calc(100vw - 2rem); padding: var(--s3) var(--s4); border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-base); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: fade-in .2s ease backwards; }

/* ── อ่านง่ายขึ้น (ตัวใหญ่ขึ้น เข้มขึ้น ขอบในการ์ดกว้างขึ้น) — ปรับเฉพาะเนื้อหาฟอร์ม ไม่แตะหัวเว็บ ── */
/* ป๊อปอัป (.fm-modal) ถูกเติมต่อท้าย <body> อยู่นอก .fm-main จึงเคยได้ตัวอักษรขนาดจอคอมที่ใหญ่กว่าเนื้อหาฟอร์ม → ใช้ขนาดชุดเดียวกัน */
.fm-main, .fm-modal {
  --fs-sm: clamp(.8125rem, .79rem + .15vw, .9rem);
  --fs-base: clamp(.875rem, .84rem + .2vw, .975rem);
  --fs-md: clamp(.9375rem, .9rem + .2vw, 1.0625rem);
  --fs-lg: clamp(1.0625rem, 1rem + .4vw, 1.25rem);
  --ink-2: #3a3a3f;  --ink-3: #55555b;
}
/* ข้อความที่ไม่ได้กำหนดขนาดเอง (ตัวเลือก ปุ่มเลือกไฟล์ คำอธิบายใต้ชื่อฟอร์ม ข้อความในการ์ดแจ้ง) เคยสืบทอดขนาดจอคอม 17px ใหญ่กว่าคำถาม 15px → ให้เท่ากัน */
@media (min-width: 640px) { .fm-main { font-size: var(--fs-md); } }
/* ระยะห่างตัวอักษรกับขอบการ์ด: ปรับตามความกว้างจอแบบต่อเนื่อง (มือถือเล็ก ~24px → มือถือใหญ่ ~28px → แท็บเล็ต/คอม 40px) */
.fm-main { --fm-px: clamp(1.125rem, .8rem + 3vw, 2.5rem); --fm-py: clamp(1.25rem, 1rem + 2.6vw, 2.25rem); }
.fm-card:not(.fm-h):not(.fm-empty), .fm-q { padding: var(--fm-py) var(--fm-px); }
.fm-card.fm-gate:not(.fm-h):not(.fm-empty), .fm-card.fm-ok:not(.fm-h):not(.fm-empty) { padding-block: calc(var(--fm-py) * 1.4); }
.fm-empty { padding: calc(var(--fm-py) * 1.4) var(--fm-px); }
.fm-h summary { padding: var(--s4) var(--fm-px); }
.fm-h dl { padding: var(--s4) var(--fm-px) var(--fm-py); }
.fm-head { border-top: 8px solid var(--fm-accent, var(--brand)); }
.fm-head h1 { font-size: clamp(1.25rem, 1.1rem + .8vw, 1.625rem); line-height: 1.3; }
.fm-rich { font-size: var(--fs-md); line-height: 1.7; }
.fm-rich ul { padding-left: 1.25rem; }                                          /* จุด bullet ชิดข้อความขึ้น ได้พื้นที่บรรทัดเพิ่ม */
.fm-bar i { background: var(--fm-accent, var(--brand)); }

/* ── รูปแบนเนอร์ด้านบนฟอร์ม ── */
.fm-banner { display: block; width: 100%; height: auto; aspect-ratio: 3286 / 860; object-fit: cover; margin-bottom: var(--s3); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); background: var(--soft-2); }

/* ── ป๊อปอัปให้ล็อกอิน (ขึ้นตอนกด “ถัดไป / ส่ง” ถ้ายังไม่ล็อกอิน) ── */
body.fm-lock { overflow: hidden; }
.fm-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s4); background: rgba(11, 11, 12, .5); }
.fm-modal-box { width: 100%; max-width: 420px; max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: var(--s3); justify-items: center; text-align: center; padding: var(--s6) var(--s5) var(--s5); background: #fff; border-radius: var(--r-card); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.fm-modal-box h2 { font-size: 1.125rem; font-weight: 700; }
.fm-modal { font-size: var(--fs-base); }
.fm-modal-box p { color: var(--ink-2); line-height: 1.7; font-size: var(--fs-md); }
.fm-modal-box .btn { width: 100%; }
.fm-modal-box .fm-line-btn { width: 100%; }
.btn-danger { background: var(--red-tint); color: var(--red-ink); border-color: #f3c9c6; }

/* ── รูปเล็กข้างชื่อฟอร์ม (ขนาดเท่ารูปในคิวกดบัตร: 48px มือถือ / 64px จอ ≥640px) ── */
.fm-pic { flex: none; display: block; width: 48px; height: 48px; overflow: hidden; border-radius: var(--r-tile); background: var(--soft); }
.fm-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 640px) { .fm-pic { width: 64px; height: 64px; } }
.fm-titlerow { display: flex; align-items: center; gap: var(--s3); }
.fm-titlerow h1 { min-width: 0; }

/* ── ฟอนต์ที่แอดมินเลือกให้ฟอร์ม (เฉพาะเนื้อหาฟอร์ม ไม่แตะแถบเมนู/ส่วนท้าย) ── */
body.fm-font .fm-main, body.fm-font .fm-main :where(button, input, textarea, select) { font-family: var(--fm-font); }

/* ==========================================================================
   Motion — ให้ลื่นขึ้น (ใช้เฉพาะ transform / opacity ที่เครื่องทำได้ลื่น · ถ้าเครื่องตั้ง “ลดการเคลื่อนไหว” main.css ปิดให้เองทั้งหมด)
   ========================================================================== */

/* ไม่ให้ smooth-scroll ของทั้งเว็บมาทำให้การเปลี่ยนหน้า/ส่วนไหลแปลก ๆ และกันหน้ากระตุกตอนเปิดป๊อปอัป */
html:has(body.fm) { scroll-behavior: auto; scrollbar-gutter: stable; }
body.fm { transition: background-color .35s var(--ease); }

/* เนื้อหาเข้าแบบไล่ขึ้นทีละส่วน (เฉพาะ 8 ชิ้นแรก ไม่ทำให้ฟอร์มยาวหนัก) */
.fm-main > :not(.fm-loading):not(form) { animation: rise .38s var(--ease) both; }
.fm-main > :nth-child(2) { animation-delay: .04s; } .fm-main > :nth-child(3) { animation-delay: .08s; }
.fm-main > :nth-child(4) { animation-delay: .12s; } .fm-main > :nth-child(5) { animation-delay: .16s; }
.fm-main > form > :nth-child(-n+8) { animation: rise .38s var(--ease) both; animation-delay: .12s; }
.fm-main > form > :nth-child(2) { animation-delay: .16s; } .fm-main > form > :nth-child(3) { animation-delay: .2s; }
.fm-main > form > :nth-child(4) { animation-delay: .24s; } .fm-main > form > :nth-child(5) { animation-delay: .28s; }
.fm-main > form > :nth-child(n+6) { animation-delay: .3s; }
.fm-who:not([hidden]):not([data-cached]) { animation: fade-in .3s ease both; }

/* เปลี่ยนหน้าแบบ cross-fade นุ่ม ๆ โดยให้แถบหัวอยู่นิ่ง (Chrome / Safari รุ่นใหม่; ที่ไม่รองรับก็ข้ามไป) */
@view-transition { navigation: auto; }
/* ใช้เฉพาะจอคอม: view-transition-name ทำให้ลูกหลานแบบ fixed (แถบเมนูล่างบนมือถือ) ติดอยู่ในหัวเว็บ */
@media (min-width: 900px) { .fm .top { view-transition-name: fm-top; } }
::view-transition-old(fm-top), ::view-transition-new(fm-top) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }
.fm-bar i { transition: width .55s var(--ease); }

/* ปุ่ม/การ์ด/ช่องกรอก: เปลี่ยนสถานะนุ่มขึ้น + กดแล้วมีแรงตอบสนอง */
.fm-q { transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.fm-in, .fm-ta, .fm-sel { transition: background-color .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease); }
.fm-in:focus, .fm-ta:focus, .fm-sel:focus { box-shadow: 0 0 0 4px var(--brand-tint); }
.fm-opt { transition: background-color .16s var(--ease), transform .12s var(--ease); }
.fm-opt:active { transform: scale(.985); }
.fm-pick { transition: border-color .18s var(--ease), transform .12s var(--ease); }
.fm-pick:active { transform: scale(.98); }
.fm-item { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.fm-line-btn { transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease); }
.fm-thumb, .fm-pic img { transition: opacity .25s ease; }
.fm-err { animation: fade-in .2s ease both; }
.has-err .fm-err { display: block; }

/* ป๊อปอัปล็อกอิน: เฟดเข้า-ออก + กล่องเด้งขึ้นเล็กน้อย */
.fm-modal { animation: fade-in .2s ease backwards; transition: opacity .16s ease; }
.fm-modal.out { opacity: 0; pointer-events: none; }
.fm-modal-box { animation: pop .28s var(--ease) backwards; }

/* ประวัติของฉัน: การ์ดกาง/พับแบบเลื่อน (เบราว์เซอร์ใหม่) + ลูกศรหมุน · เบราว์เซอร์เก่าจะเฟดแทน */
:root { interpolate-size: allow-keywords; }
.fm-h::details-content { block-size: 0; overflow: clip; transition: block-size .32s var(--ease), content-visibility .32s allow-discrete; }
.fm-h[open]::details-content { block-size: auto; }
.fm-h[open] > dl { animation: fade-in .3s ease both; }
.fm-h summary { -webkit-tap-highlight-color: transparent; transition: background-color var(--dur) var(--ease); }
.fm-h summary:active { background: var(--soft); }
.fm-h summary::after { content: ''; flex: none; width: 8px; height: 8px; margin: 0 var(--s1) 3px 2px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .28s var(--ease); }
.fm-h[open] summary::after { transform: rotate(-135deg); margin-bottom: -3px; }
.fm-h { transition: box-shadow .2s var(--ease); }
.fm-ct-body { display: grid; gap: var(--s4); margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.fm-ct-sum { display: grid; margin: 0; padding: 0 var(--s4); background: var(--soft); border-radius: 16px; }
.fm-ct-sum > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line-2); }
.fm-ct-sum > div:first-child { border-top: 0; }
.fm-ct-sum dt { color: var(--ink-2); font-size: var(--fs-sm); }
.fm-ct-sum dd { margin: 0; font-weight: 700; font-size: var(--fs-md); text-align: right; overflow-wrap: anywhere; }
.fm-ct-sum .left dd { color: var(--red-ink); }
.fm-ct-h { margin: 0; font-size: var(--fs-base); font-weight: 700; }
.fm-pays { display: grid; list-style: none; margin: calc(var(--s2) * -1) 0 0; padding: 0; }
.fm-pays li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.fm-pays li:first-child { border-top: 0; }
.fm-pays b { display: block; font-weight: 600; font-size: var(--fs-base); }
.fm-pays small { display: block; margin-top: 2px; color: var(--ink-3); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.fm-pay-l { min-width: 0; }
.fm-pay-r { flex: none; font-weight: 700; font-size: var(--fs-md); color: var(--green-ink); white-space: nowrap; }
.fm-ct-empty { margin: 0; padding: var(--s4); text-align: center; color: var(--ink-3); font-size: var(--fs-sm); background: var(--soft); border-radius: 14px; }
.fm-ct-hint { margin: 0; color: var(--ink-3); font-size: var(--fs-sm); line-height: 1.6; }
.fm-ct-body[hidden] { display: none; }
.fm-ct-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.fm-ct-head > div { min-width: 0; }
.fm-ct-head b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.fm-ct-head small { color: var(--ink-3); font-size: var(--fs-sm); }
.fm-ct { display: grid; gap: 0; }
.fm-ct-next { margin-top: var(--s2); }
.fm-ct-acts { display: flex; gap: var(--s2); margin-top: var(--s3); }
.fm-sbtn { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 var(--s3); border-radius: 999px; font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap; transition: background-color .18s, transform .12s, border-color .18s; }
.fm-sbtn:active { transform: scale(.97); }
.fm-sbtn svg { width: 16px; height: 16px; flex: none; }
.fm-sbtn-main { border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); }
.fm-sbtn-sub { border: 1px solid var(--line-2); background: #fff; color: var(--ink); }
.fm-chev { width: 7px; height: 7px; margin-top: -3px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .24s var(--ease); }
.fm-sbtn-sub[aria-expanded="true"] .fm-chev { transform: rotate(-135deg); margin-top: 3px; }


/* ==========================================================================
   Responsive polish — ทุกขนาดจอ / ทุกอุปกรณ์
   ========================================================================== */
/* มือถือเล็ก: ปุ่มย้อนกลับ/ถัดไปเรียงเป็นแถวเต็มความกว้าง กดง่ายด้วยนิ้วโป้ง */
@media (max-width: 399px) {
  .fm-actions { flex-direction: column-reverse; }
  .fm-actions .btn, .fm-actions .btn-ghost { flex: 1 1 auto; width: 100%; }
  .fm-item { padding: var(--s3); }
  .fm-me-name { display: none; }
}
@media (max-width: 359px) {
  .fm-opt { gap: var(--s2); padding-inline: var(--s2); }
  .fm-thumb img { width: 52px; height: 52px; }
}
/* จอแท็บเล็ต/คอม: ฟอร์มกว้างขึ้นอีกนิด อ่านสบายตา */
@media (min-width: 900px) { .fm-main { max-width: 760px; } }
@media (min-width: 1600px) { .fm-main { max-width: 840px; } }
/* จอเตี้ย (มือถือแนวนอน): ลดช่องว่าง + ป๊อปอัปเลื่อนได้ */
@media (max-height: 480px) {
  .fm-main { padding-top: var(--s2); }
  .fm-modal { padding: var(--s2); }
  .fm-modal-box { padding: var(--s4) var(--s4) var(--s3); gap: var(--s2); }
}
/* จอสัมผัส: ปุ่ม/ตัวเลือกกดง่าย (≥44px) */
@media (pointer: coarse) {
  .fm-opt input { width: 24px; height: 24px; }
  .fm-opt { min-height: 52px; }
  .fm-me, .fm-login, .fm-menu-out { min-height: 46px; }
  .fm-link { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ── สัญญาจะซื้อจะขาย (/contract/<token>) ───────────────────────────────── */
.fm-con-head p { margin: var(--s2) 0 0; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.7; }
.fm-con-sum { margin-top: var(--s3); }
.fm-con-sum dd small { display: block; margin-top: 2px; font-weight: 400; color: var(--ink-3); font-size: var(--fs-sm); }
.fm-con-pre { margin: var(--s2) 0 0; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.75; overflow-wrap: anywhere; }
.fm-con-terms { display: grid; gap: var(--s4); margin-top: var(--s4); }
.fm-con-terms h3 { margin: 0 0 var(--s2); font-size: var(--fs-md); font-weight: 700; line-height: 1.5; }
.fm-con-terms p { margin: 0 0 var(--s2); color: var(--ink-2); line-height: 1.8; overflow-wrap: anywhere; }
.fm-con-terms p.d1 { padding-left: 1.1rem; }
.fm-con-terms p.d2 { padding-left: 2.2rem; }
.fm-con-soc { display: grid; gap: var(--s3); }
.fm-con-soc label { display: grid; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.fm-con-files { display: grid; gap: var(--s2); }
.fm-con-file { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.fm-con-file img, .fm-con-file .pdf { flex: none; width: 52px; height: 52px; border-radius: 10px; border: 1px solid var(--line); background: #fff; object-fit: cover; }
.fm-con-file .pdf { display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; color: var(--red-ink); }
.fm-con-file span:not(.pdf) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: var(--fs-sm); }
.fm-con-file .fm-link { flex: none; }
.fm-con-files .fm-pick { width: 100%; }
.fm-con-sum dt { flex: 1 1 0; min-width: 0; }
.fm-con-sum dd { flex: 0 1 auto; max-width: 62%; overflow-wrap: break-word; }
.fm-con-soc .fm-in { font-weight: 400; }

.fm-linkbtn { display: inline; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: inherit; text-decoration: underline; cursor: pointer; }
a.fm-line-btn { text-decoration: none; }
