/* help.css · หน้าต่างช่วยเหลือ (ปุ่ม "?" · แป้น ?) · lane U2 เป็นเจ้าของไฟล์นี้
   ต้นแบบ: 4-design/help/help-modal-mockup.html · ข้อกำหนด: 4-design/app-redesign/DESIGN-TOKENS.md
   สีทั้งหมดเป็นตัวแปรของชุดสี (themes.css) · ไม่มีสีเขียนตรง (TestHelpCSSUsesTokensOnly) · token ใหม่ของ redesign (--ring --scrim --hatch --shadow-3)
   มีค่าสำรองจาก token เดิม ใช้ได้ทั้งก่อนและหลัง lane U1 เพิ่ม token · ตัวอักษรไทย line-height ≥ 1.45 · ไม่มี overflow:hidden บนบรรทัดไทยแคบ */

:root {
  --hm-ring: var(--ring, var(--brand));
  --hm-scrim: var(--scrim, color-mix(in srgb, var(--ink) 46%, transparent));
  --hm-hatch: var(--hatch, color-mix(in srgb, var(--vendor-fg) 16%, transparent));
  --hm-shadow: var(--shadow-3, 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent), 0 12px 32px color-mix(in srgb, var(--ink) 14%, transparent), 0 40px 80px -24px color-mix(in srgb, var(--ink) 30%, transparent));
  --hm-mono: var(--font-mono, "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace);
}
[data-mode="dark"] {
  --hm-scrim: var(--scrim, color-mix(in srgb, var(--bg) 72%, transparent));
  --hm-shadow: var(--shadow-3, 0 0 0 1px color-mix(in srgb, var(--fg) 6%, transparent), 0 18px 48px color-mix(in srgb, var(--bg) 80%, transparent), 0 48px 96px -24px color-mix(in srgb, var(--bg) 90%, transparent));
}
@media (prefers-color-scheme: dark) {
  [data-mode="system"] {
    --hm-scrim: var(--scrim, color-mix(in srgb, var(--bg) 72%, transparent));
    --hm-shadow: var(--shadow-3, 0 0 0 1px color-mix(in srgb, var(--fg) 6%, transparent), 0 18px 48px color-mix(in srgb, var(--bg) 80%, transparent), 0 48px 96px -24px color-mix(in srgb, var(--bg) 90%, transparent));
  }
}

/* ── ปุ่ม "?" บนแถบบน (ขอบ --input · ตัวอักษร --fg · เปิดอยู่ = พื้น --soft) ── */
/* ขนาด/รูปทรงมาจาก .iconbtn.helpbtn ของโครงหน้า (css/base.css · css/shell.css · lane U1) · ที่นี่เพิ่มเฉพาะสถานะของหน้าต่างช่วยเหลือ */
.help-btn[aria-expanded="true"] { background: var(--soft); border-color: var(--brand); }
.help-btn:focus-visible { outline: 2px solid var(--hm-ring); outline-offset: 2px; }
.help-btn.htmx-request { cursor: progress; }
.pub .help-btn, .pt .help-btn { margin-left: 4px; }
.help-root:empty { display: none; }
body.hm-locked { overflow: hidden; }

/* ── ฉากหลัง + กล่อง ── */
.hm-scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--hm-scrim);
  -webkit-backdrop-filter: saturate(.8) blur(2px); backdrop-filter: saturate(.8) blur(2px);
  opacity: 0; transition: opacity .18s ease;
}
.hm-scrim[hidden], .hm[hidden] { display: none; }
.hm-scrim.in { opacity: 1; }
.hm {
  position: fixed; z-index: 61; left: 50%; top: 50%;
  width: min(960px, calc(100vw - 48px)); height: min(736px, calc(100vh - 32px)); height: min(736px, calc(100dvh - 32px));
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--surf); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--hm-shadow);
  overflow: hidden; font-size: 14px; line-height: 1.6; font-feature-settings: "tnum";
  transform: translate(-50%, -48%) scale(.985); opacity: 0;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .7, .2, 1);
}
.hm.in { opacity: 1; transform: translate(-50%, -50%); }
.hm *, .hm *::before, .hm *::after { box-sizing: border-box; }
.hm :focus-visible { outline: 2px solid var(--hm-ring); outline-offset: 2px; border-radius: 6px; }
.hm .vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hm kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px;
  font: 500 12px/1 var(--hm-mono); color: var(--ink2); background: var(--surf);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; white-space: nowrap;
}
.hm-ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ── หัว ── */
.hm-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; padding: 22px 28px 14px; }
.hm-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 12.5px; line-height: 1.5; color: var(--muted); font-weight: 500; min-width: 0; flex-wrap: wrap; }
.hm-eyebrow .q { width: 22px; height: 22px; border-radius: 50%; background: var(--soft); color: var(--fg); display: inline-grid; place-items: center; font-weight: 700; font-size: 12.5px; line-height: 1; }
.hm-eyebrow .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--input); }
.hm-head h2 { margin: 6px 0 4px; font-size: 24px; line-height: 1.45; font-weight: 600; letter-spacing: -.003em; color: var(--ink); }
.hm-head h2:focus { outline: none; }
.hm-head h2:focus-visible { outline: 2px solid var(--hm-ring); outline-offset: 4px; }
.hm-lede { margin: 0; color: var(--ink2); font-size: 14.5px; line-height: 1.7; max-width: 84ch; grid-column: 1 / -1; }
.hm-lede b { color: var(--ink); font-weight: 600; }
.hm-ctl { display: flex; align-items: flex-start; gap: 8px; grid-row: 1 / 3; grid-column: 2; }
.hm-toggle { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surf2); height: 36px; margin: 0; }
.hm-toggle button {
  border: 0; background: transparent; border-radius: 7px; padding: 0 10px; min-width: 38px; min-height: 30px;
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center;
}
.hm-toggle button:hover { color: var(--ink); }
.hm-toggle button[aria-pressed="true"] { background: var(--surf); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent); }
.hm-close {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surf); color: var(--ink2);
  display: inline-grid; place-items: center; cursor: pointer; padding: 0;
}
.hm-close:hover { background: var(--surf2); }

/* ── แถบหัวข้อ ── */
.hm-nav { display: flex; gap: 2px; padding: 0 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.hm-nav::-webkit-scrollbar { display: none; }
.hm-nav a {
  display: flex; align-items: center; gap: 7px; padding: 9px 10px 11px; min-height: 40px; color: var(--muted); text-decoration: none;
  font-size: 13.5px; line-height: 1.5; white-space: nowrap; border-radius: 6px 6px 0 0;
}
.hm-nav a:hover { color: var(--ink); }
.hm-nav a[aria-current="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }

/* ── เนื้อหา ── */
.hm-body { overflow-y: auto; overscroll-behavior: contain; padding: 20px 28px 26px; scroll-padding-top: 12px; }
.hm-body:focus-visible { outline-offset: -3px; }
.hm-sec { scroll-margin-top: 12px; }
.hm-sec + .hm-sec { margin-top: 26px; }
.hm-sec-h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.hm-sec-h h3 { margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.hm-sec-h p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.hm-grid2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 26px; margin-top: 26px; }
.hm-grid2 .hm-sec + .hm-sec { margin-top: 0; }
.hm-grid2.one { grid-template-columns: minmax(0, 1fr); }
.hm-sec-iso { margin-top: 26px; }
.hm-flowbox + .hm-sec-iso { margin-top: 26px; }

/* ผังงาน */
.hm-flowbox { border: 1px solid var(--line); border-radius: 12px; background: var(--surf2); }
.hm-fb-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; flex-wrap: wrap; }
.hm-fb-top h3 { margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.hm-badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; line-height: 1.5; font-weight: 500; background: var(--surf); border: 1px solid var(--line); color: var(--ink2);
}
.hm-badge.custom { background: var(--purple-bg); border-color: transparent; color: var(--purple-fg); }
.hm-badge .hm-ico { width: 14px; height: 14px; }
.hm-pos { margin-left: auto; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.hm-pos b { color: var(--ink); font-weight: 600; }
.hm-svg { padding: 4px 8px 0; }
.hm-svg.wide { overflow-x: auto; }
.hm-svg.wide:focus-visible { outline: 2px solid var(--hm-ring); outline-offset: -2px; }
.hf { display: block; max-width: 100%; height: auto; margin: 0 auto; font-family: inherit; }
.hm-svg.wide .hf { width: auto; max-width: none; }
.hf text { font-family: inherit; }
.hf-mk { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hf-mk-v { stroke: var(--vendor-fg); }
.hf-hb { fill: var(--vendor-bg); }
.hf-hl { fill: var(--hm-hatch); }
.hf-band { stroke: var(--vendor-fg); stroke-width: 1.2; stroke-dasharray: 5 4; stroke-opacity: .7; }
.hf-e { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.hf-loop { stroke-width: 1.4; stroke-dasharray: 4 4; }
.hf-dl { fill: none; stroke: var(--vendor-fg); stroke-width: 1.4; stroke-dasharray: 4 4; }
.hf-lp { fill: var(--surf2); stroke: var(--line); }
.hf-lt { fill: var(--ink2); font-size: 12px; }
.hf-box { fill: var(--surf); stroke: var(--input); stroke-width: 1.25; }
.hf-l { fill: var(--ink2); font-size: 13.5px; font-weight: 600; }
.hf-sub { fill: var(--muted); font-size: 12px; }
.hf-s-done .hf-box { fill: var(--soft); stroke: none; }
.hf-s-done .hf-l, .hf-s-done .hf-sub { fill: var(--fg); }
.hf-s-current .hf-box { fill: var(--brand); stroke: none; }
.hf-s-current .hf-l, .hf-s-current .hf-sub { fill: var(--on-brand); }
.hf-s-current .hf-sub { fill-opacity: .92; }
.hf-halo { fill: none; stroke: var(--brand); stroke-opacity: .28; stroke-width: 3; }
.hf-s-skipped { opacity: .5; }
.hf-s-skipped .hf-box { stroke-dasharray: 4 3; }
.hf-s-detour .hf-box { fill: var(--vendor-bg); stroke: var(--vendor-fg); }
.hf-s-detour .hf-l, .hf-s-detour .hf-sub { fill: var(--vendor-fg); }
.hf-s-detour.hf-s-current .hf-box { fill: var(--vendor-fg); }
.hf-s-detour.hf-s-current .hf-l, .hf-s-detour.hf-s-current .hf-sub { fill: var(--vendor-bg); }
.hf-s-detour.hf-s-current .hf-halo { stroke: var(--vendor-fg); }
.hf-hp { fill: var(--ink); }
.hf-hd { fill: var(--brand); stroke: var(--surf); stroke-width: 1.5; }
.hf-ht { fill: var(--surf); font-size: 12px; font-weight: 600; }
.hf-ni { fill: var(--vendor-bg); stroke: var(--vendor-fg); stroke-width: 1.2; }
.hf-nb { stroke: var(--vendor-fg); stroke-width: 2; stroke-linecap: round; }
.hf-nt { fill: var(--vendor-fg); font-size: 13px; font-weight: 600; }
.hf-ns { fill: var(--muted); font-size: 12px; }

.hm-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 16px 12px; margin: 0 16px; font-size: 12px; line-height: 1.5; color: var(--muted); border-top: 1px dashed var(--line); list-style: none; }
.hm-legend li { display: inline-flex; align-items: center; gap: 7px; }
.hm-sw { width: 18px; height: 12px; border-radius: 4px; display: inline-block; flex: none; }
.hm-sw.done { background: var(--soft); }
.hm-sw.cur { background: var(--brand); }
.hm-sw.next { background: var(--surf); box-shadow: inset 0 0 0 1.25px var(--input); }
.hm-sw.pause { background: repeating-linear-gradient(135deg, var(--vendor-bg) 0 3px, var(--hm-hatch) 3px 5px); box-shadow: inset 0 0 0 1.25px var(--vendor-fg); }
.hm-sw.loop { width: 22px; height: 0; border-top: 1.6px dashed var(--muted); border-radius: 0; }
.hm-wfnote { display: flex; align-items: flex-start; gap: 10px; margin: 0 16px 14px; padding: 10px 12px; border-radius: 9px; background: var(--purple-bg); color: var(--purple-fg); font-size: 13px; line-height: 1.6; }
.hm-wfnote b { font-weight: 600; }
.hm-wfnote .hm-ico { margin-top: 2px; }
.hm-flowbox > .hm-legend:last-child, .hm-flowbox > .hm-svg:last-child { margin-bottom: 4px; }

/* รายการข้อความแทนผัง: จอใหญ่ซ่อนให้เหลือเฉพาะโปรแกรมอ่านหน้าจอ · จอ ≤ 640px แสดงเป็นขั้นแนวตั้ง */
.hm-flowlist { list-style: none; margin: 0; padding: 0; }
.hm-flowlist.hm-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.hm-flowlist > li { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 6px 0 10px; }
.hm-flowlist > li::before { content: ""; position: absolute; left: 10px; top: 28px; bottom: -4px; width: 2px; background: var(--line); }
.hm-flowlist > li:last-child::before { display: none; }
.hm-flowlist .m { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1; background: var(--surf); box-shadow: inset 0 0 0 1.5px var(--input); color: var(--muted); position: relative; z-index: 1; }
.hm-flowlist .done > .m { background: var(--soft); box-shadow: none; color: var(--fg); }
.hm-flowlist .current > .m { background: var(--brand); box-shadow: 0 0 0 4px var(--soft); color: var(--on-brand); }
.hm-flowlist b { font-weight: 600; font-size: 14px; line-height: 1.5; }
.hm-flowlist .current > div > b { color: var(--fg); }
.hm-flowlist small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.hm-flowlist .here { display: inline-flex; align-items: center; margin-left: 8px; min-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 600; line-height: 1.5; vertical-align: 2px; }
.hm-flowlist ul { list-style: none; margin: 8px 0 0; padding: 8px 10px; border-radius: 9px; border: 1.25px dashed var(--vendor-fg);
  background: repeating-linear-gradient(135deg, var(--vendor-bg) 0 6px, color-mix(in srgb, var(--vendor-bg) 82%, var(--vendor-fg)) 6px 8px); color: var(--vendor-fg); }
.hm-flowlist ul li { padding: 3px 0; }
.hm-flowlist ul b, .hm-flowlist ul small { color: var(--vendor-fg); }
.hm-flowlist ul b { font-size: 13px; }
.hm-flowlist ul .current b { text-decoration: underline; text-underline-offset: 3px; }
.hm-flowlist .pz { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1.5; margin-bottom: 2px; }

/* ปุ่ม · แป้นลัด */
.hm-keys { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.hm-keys li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.hm-keys li:first-child { border-top: 0; }
.hm-keys b { font-weight: 600; font-size: 13.5px; line-height: 1.5; }
.hm-keys small { grid-column: 1; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.hm-keys .k { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
.hm-keys .ui { font-size: 12px; line-height: 1.5; color: var(--muted); border: 1px dashed var(--input); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.hm-tap { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.hm-tap li { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--input); background: var(--surf); font-size: 14px; font-weight: 500; color: var(--ink2); }
.hm-tap li:first-child { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* กติกา */
.hm-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hm-rules li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 11px 14px 11px 12px; border-radius: 10px; background: var(--surf2); }
.hm-rules .ri { width: 28px; height: 28px; border-radius: 8px; background: var(--surf); border: 1px solid var(--line); display: grid; place-items: center; color: var(--fg); }
.hm-rules .ri .hm-ico { width: 15px; height: 15px; }
.hm-rules b { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.55; }
.hm-rules small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.55; margin-top: 1px; }

/* หลักฐาน ISO */
.hm-iso { border: 1px solid var(--line); border-radius: 12px; }
.hm-iso-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.hm-iso-row:first-child { border-top: 0; }
.hm-iso-row .when { font-size: 13.5px; line-height: 1.55; }
.hm-iso-row .when small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
.hm-iso-row .cs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hm-std { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 7px; font: 500 12px/1 var(--hm-mono); background: var(--surf); border: 1px solid var(--line); color: var(--ink2); white-space: nowrap; }
.hm-std i { font-style: normal; font-family: var(--font-sans, "Anuphan", "Noto Sans Thai", system-ui, sans-serif); font-size: 12px; color: var(--muted); font-weight: 500; }
.hm-std.got { background: var(--teal-bg); border-color: transparent; color: var(--teal-fg); }
.hm-std.got i { color: var(--teal-fg); }
.hm-std .hm-ico { width: 13px; height: 13px; stroke-width: 2.2; }
.hm-iso-foot { padding: 9px 14px; background: var(--surf2); font-size: 12.5px; line-height: 1.55; color: var(--muted); display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.hm-iso-foot .hm-ico { width: 15px; height: 15px; }

/* หมายเหตุของหน่วยงาน + ปุ่มท้าย */
.hm-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 14px 28px; border-top: 1px solid var(--line); background: var(--surf2); }
.hm-tnote { display: grid; gap: 2px 12px; align-items: start; padding-left: 12px; border-left: 3px solid var(--p2); min-width: 0; }
.hm-tnote .lbl { font-size: 12px; line-height: 1.5; font-weight: 600; color: var(--p2-fg); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hm-tnote .lbl span { font-weight: 400; color: var(--muted); }
.hm-tnote p { margin: 0; font-size: 13px; color: var(--ink2); line-height: 1.6; overflow-wrap: anywhere; }
.hm-tnote a { font-size: 12px; color: var(--fg); }
.hm-tnote-m { display: none; }
.hm-acts { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.hm-acts .esc { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; white-space: nowrap; }
.hm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--input); background: var(--surf); color: var(--ink2); font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.hm-btn:hover { background: var(--surf2); }
.hm-btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; min-width: 64px; }
.hm-btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.hm-btn.ghost { border-color: transparent; background: transparent; color: var(--fg); }
.hm-btn.ghost:hover { background: var(--sel); }
.hm-btn .hm-ico { width: 15px; height: 15px; }

/* หน้าที่ไม่มี JS (เปิด /help/<key> ตรง) · หน้าต่างแสดงเป็นเนื้อหาของหน้า */
.hm.static { position: static; transform: none; opacity: 1; width: auto; height: auto; max-width: 1040px; margin: 0 auto; }
.hm.static .hm-body { overflow: visible; }

/* หน้าตั้งค่า › หมายเหตุในหน้าช่วยเหลือ */
.hn-intro { max-width: 70ch; color: var(--ink2); }
.hn-table td small { display: block; color: var(--muted); }
.hn-note { max-width: 46ch; overflow-wrap: anywhere; }
.hn-form { display: grid; gap: 14px; max-width: 46rem; }
.hn-form textarea { width: 100%; min-height: 6.5rem; font: inherit; line-height: 1.6; }
.hn-preview { border-left: 3px solid var(--p2); padding-left: 12px; }

/* ── ≤ 900px: ผังเต็มกว้างยังอ่านได้ ── */
@media (max-width: 900px) {
  .hm-grid2 { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

/* ── ≤ 640px · แผ่นล่างเต็มความสูง (มือจับ · ปุ่ม 44px · ผังเป็นขั้นแนวตั้ง) ── */
@media (max-width: 640px) {
  .hm {
    left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: calc(100vh - 12px); height: calc(100dvh - 12px);
    border-radius: 18px 18px 0 0; border-bottom: 0; transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom);
  }
  .hm.in { transform: none; }
  .hm::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
  .hm-head { grid-template-columns: minmax(0, 1fr); padding: 22px 16px 10px; }
  .hm-ctl { grid-row: 1; grid-column: 1; margin: 0 0 10px; }
  .hm-ctl .hm-close { margin-left: auto; }
  .hm-head .hm-eyebrow { grid-row: 2; }
  .hm-head h2 { grid-row: 3; font-size: 21px; margin-top: 4px; }
  .hm-head .hm-lede { grid-row: 4; font-size: 14px; }
  .hm-nav { padding: 0 10px; -webkit-mask-image: linear-gradient(90deg, var(--ink) 85%, transparent); mask-image: linear-gradient(90deg, var(--ink) 85%, transparent); }
  .hm-body { padding: 14px 16px 22px; }
  .hm-svg, .hm-legend, .hm-pos { display: none; }
  .hm-fb-top { padding: 12px 14px 4px; }
  .hm-flowlist.hm-sr { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; clip-path: none; white-space: normal; padding: 4px 14px 14px; }
  .hm-wfnote { margin: 0 14px 14px; }
  .hm-iso-row { grid-template-columns: minmax(0, 1fr); }
  .hm-iso-row .cs { justify-content: flex-start; }
  .hm-foot { grid-template-columns: minmax(0, 1fr); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .hm-foot .hm-tnote { display: none; }
  .hm-tnote-m { display: grid; margin-top: 24px; }
  .hm-acts { justify-content: space-between; }
  .hm-acts .esc { display: none; }
  .hm-acts .hm-btn.primary { flex: 1; height: 44px; }
  .hm-acts .hm-btn.ghost { height: 44px; }
  .hm-close { height: 44px; }
  .hm-toggle { height: auto; padding: 1px; }
  .hm-close { width: 44px; }
  .hm-toggle button { min-width: 46px; min-height: 44px; }
  .hm-nav a { min-height: 44px; }
  .hm-keys .k { grid-row: auto; grid-column: 1; margin-top: 4px; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .hm, .hm-scrim, .hm *, .hm *::before, .hm *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print { .hm, .hm-scrim, .help-btn { display: none !important; } }
