/* ============================================================
   พื้นที่ทำงานของคดี (หลังบ้าน) — เมนูซ้าย · แถบขั้นตอน · ฟอร์มทุกแท็บ
   โหลดต่อจาก app.css (ชนะกฎเดิมเมื่อน้ำหนักเท่ากัน)
   ระบบ: ระยะ 4/8/12/16/24/32 · มุมโค้ง การ์ด 16 / ช่องกรอก 10 · สีจาก token ใน app.css
   ============================================================ */

/* ค่าพื้นฐานที่ย้ายมาจาก app.css (ส่วนที่ไม่มีใน “ชุดเดิม” ซึ่งลบออกแล้ว) */
.steps .nav-item { display: flex; width: 100%; align-items: center; text-align: left; border: 0; background: transparent; cursor: pointer; line-height: 1.3; transition: background-color .12s, color .12s; }
.nav-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.nav-head small { white-space: nowrap; font-weight: 500; border-radius: 99px; padding: 0 8px; color: #a8450c; }
.nav-ico { display: grid; place-items: center; flex: none; }
.nav-count { border-radius: 99px; font-weight: 700; }
.steps .badge { background: var(--err); color: #fff; border-radius: 99px; font-weight: 700; }
.dot { border-radius: 50%; }
.panel > h3, .sec-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; line-height: 1.4; }
.fact { display: grid; align-items: start; }
.fact .ctl { display: flex; }
.vars h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wiz-miss ul { margin: 6px 0 0; }
.wiz-btns .btn.primary.is-locked { cursor: not-allowed; }
/* ---------- เมนูซ้าย ---------- */
:root { --nav-w: 232px; }
@media (max-width: 1100px) { :root { --nav-w: 208px; } }
.work > .steps { background: #fff; border-right: 1px solid var(--hair-2); padding: 8px 12px 24px; scrollbar-width: thin; scrollbar-color: #d5d7de transparent; }
.nav-group { margin-bottom: 4px; }
.nav-head { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted-2); padding: 12px 12px 4px; }
.nav-head small { background: var(--blue-soft); }
.steps .nav-item { gap: 10px; min-height: 38px; padding: 3px 10px; border-radius: var(--r-ctl); font-size: 15px; font-weight: 500; color: var(--ink-2); }
.steps .nav-item:hover { background: var(--surface-3); }
.steps .nav-item.on { background: var(--blue-soft); color: #a8450c; font-weight: 600; box-shadow: none; }
.steps .nav-item:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.nav-ico { width: 24px; height: 24px; border-radius: 8px; background: transparent; color: #7b8190; font-size: 18px; }
.nav-ico .ico { width: 19px; height: 19px; }
.nav-item:hover .nav-ico { color: var(--ink-2); }
.nav-item.on .nav-ico { background: transparent; color: var(--blue); }
.nav-count { font-size: 13px; background: var(--surface-3); color: var(--ink-2); padding: 0 8px; min-width: 22px; text-align: center; }
.nav-item.on .nav-count { background: #fff; color: #a8450c; }
.steps .badge { font-size: 13px; padding: 0 7px; }
.nav-item.locked { opacity: 1; color: #6b7280; }
.nav-item.locked .nav-ico { color: #b1b6c1; }
.nav-item .lock { margin-left: auto; display: inline-flex; color: #a4a9b4; }
.dot { display: inline-grid; place-items: center; flex: none; box-sizing: border-box; margin-left: auto; }
.dot.ok { width: 16px; height: 16px; background: var(--ok); color: #fff; }
.dot.ok .ico { width: 10px; height: 10px; }
.dot.todo { width: 12px; height: 12px; background: transparent; border: 2px solid #e8a317; }
.dot.off { width: 8px; height: 8px; background: #c5c9d2; }
.nav-count + .dot, .nav-count + .lock, .badge + .dot, .badge + .lock { margin-left: 0; }
.nav-count, .badge { margin-left: auto; }

/* ---------- เนื้อหาหลัก + หัวหน้า ---------- */
.main { padding: 40px 40px 120px; }
.main > :is(h2, h3, p, div, section, details, hr, nav, form, ol, ul) { max-width: 800px; margin-left: auto; margin-right: auto; }
.main > :is(datalist) { display: none; }
.main h2 { font-size: 26px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; margin-bottom: 6px; }
.main > .sub { max-width: 800px; }
.main .sub { font-size: 15.5px; color: var(--muted-2); margin: 0 auto 28px; line-height: 1.6; }
.main h3.part { font-size: 22px; font-weight: 700; margin: 0 auto 6px; max-width: 800px; }
.main h3.part + .sub { margin-bottom: 20px; }
.part-sep { border: 0; border-top: 1px solid var(--hair-2); margin: 48px auto 40px; }

/* ---------- การ์ด ---------- */
.panel { background: #fff; border-radius: var(--r-card); box-shadow: var(--sh-sm); border: 1px solid var(--hair-2); padding: 28px; margin-bottom: 16px; }
.panel > h3, .sec-h { font-size: 17px; font-weight: 600; letter-spacing: -.005em; color: var(--ink); margin: 0 0 20px; }
.panel > h3 .chk { font-size: 14.5px; font-weight: 400; color: var(--ink-2); }
.panel.compact { padding: 16px 20px; }
/* กล่องเอกสารที่ปิดสวิตช์ “ออกในชุดเอกสาร”: ยุบเหลือหัวข้อ + สถานะ (หน้า คำให้การ · สัญญา · อุทธรณ์) */
.panel.off { padding: 14px 20px; background: var(--surface-2, #fafafa); border-style: dashed; }
.panel.off > h3 { margin: 0; font-size: 15.5px; color: var(--ink-2); }
.panel.off > .panel-note { margin: 6px 0 0; font-size: 13px; }
.panel.spaced { margin-top: 16px; }
.panel-body { margin-top: 24px; }
.panel-foot { margin-top: 20px; }
.panel > .panel-note, .panel > h3 + .panel-note { margin: -12px 0 20px; }
.sec-h { margin: 36px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.sec-h .cnt { font-size: 14px; font-weight: 500; color: var(--muted-2); background: var(--surface-3); border-radius: 99px; padding: 0 10px; line-height: 1.7; }
.grp + .grp, .grp + .more, .grid + .grp, .grid + .grid, .panel > .grp ~ .btn-group { margin-top: 28px; }
.grp-t { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted-2); margin: 0 0 14px; }
.grp-t::after { content: ''; flex: 1; height: 1px; background: var(--hair); }
.grid > .grp-t, .agrp > .grp-t { margin-bottom: -2px; }
.grid, .agrp { gap: 20px 16px; }
.toolbar { gap: 8px; margin-bottom: 20px; }
.toolbar.foot, .item-toolbar.foot { margin: 20px 0 0; }
.toolbar.tight { margin: 0; }
.main code { font-size: 13px; }
.hint.flush { margin: 0; }
.list-count { margin: 0 0 8px; }
.src-line { margin-top: 16px; }

/* ---------- ช่องกรอก ---------- */
.f > .hint { margin-top: 0; }
.f.f-end { justify-content: flex-end; }
.sel-inline { width: auto; min-width: 180px; min-height: 38px; font-size: 14.5px; }
.sel-grow { width: auto; flex: 1; min-width: 200px; max-width: 440px; }
.row.snip-row, .snip-row { margin-top: 16px; }
.snip-wrap { margin-top: 16px; }
.dt-row { gap: 8px; }
/* เลขคดี “เลข / ปี” (ดำและแดงมีปีของตัวเองแยกกัน) */
.cn-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 92px; gap: 8px; align-items: center; }
.cn-row>* { min-width: 0; }
.cn-sl { color: var(--muted, #6e6e73); font-weight: 600; }

/* สถานะเลขบัตร: ชิปเล็ก ๆ ใต้ช่อง */
.idok { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; line-height: 1.4; }
.idok.ok { color: var(--ok); }
.idok.bad { color: var(--err); }
.idok.warn { color: var(--warn); }
.idok .ico { flex: none; }

/* ---------- การ์ดรายการแบบพับ (คู่ความ ข้อหา พยาน คำร้อง) ---------- */
details.item { border-radius: var(--r-card); border: 1px solid var(--hair-2); box-shadow: var(--sh-sm); margin-bottom: 12px; overflow: clip; }
details.item[open] { box-shadow: var(--sh-md); border-color: #d3d6de; }
details.item > summary { min-height: 60px; padding: 10px 14px 10px 16px; border-radius: 0; gap: 12px; }
details.item > summary:hover { background: var(--surface-2); }
details.item > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
details.item[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: #fcfcfd; }
details.item > .d-body { border-top: 1px solid var(--hair); padding: 28px; }
details.item > summary::before, details.more > summary::before, details.book > summary::before, details.prec > summary::before {
  width: 8px; height: 8px; margin: 0 4px 0 2px; border-right: 2px solid #8a909c; border-bottom: 2px solid #8a909c; border-radius: 1px; }
.sum-title { font-weight: 600; }
.sum-name { font-weight: 500; color: var(--ink); }
.sum-meta { font-size: 13.5px; }
.sum-main { gap: 4px 12px; }
.role-dot { width: 10px; height: 10px; box-shadow: 0 0 0 3px var(--blue-soft); }
.role-dot.defendant { box-shadow: 0 0 0 3px var(--err-bg); }
.item-toolbar { gap: 8px; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--hair); }
.item-toolbar select { min-height: 38px; font-size: 14.5px; width: auto; min-width: 140px; }
.item-toolbar.foot { border: 0; padding: 0; }
.ctag { background: var(--surface-3); color: var(--ink-2); border-radius: 8px; padding: 2px 10px; font-size: 13px; line-height: 1.5; }

/* ข้อมูลเพิ่มเติม (เปิด/ปิด) */
details.more { margin-top: 28px; }
details.more > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 10px; margin-left: 0; border-radius: 99px; background: var(--blue-soft); transition: background-color .15s; }
details.more > summary:hover { background: #dcebfd; }
details.more > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.more-t { font-size: 14px; color: #a8450c; }
details.more > summary .hint { margin-left: 4px; color: #5a6b85; font-size: 13px; }
details.more > .d-body { margin-top: 20px; }
details.more > summary::before { border-color: #a8450c; }
.grid > details.more { margin-top: 8px; }

/* สมุดรายชื่อ */
details.book { border-radius: var(--r-card); border: 1px solid var(--hair-2); box-shadow: var(--sh-sm); margin-bottom: 28px; overflow: clip; }
details.book > summary { min-height: 56px; padding: 10px 16px; border-radius: 0; gap: 10px; }
details.book > summary:hover { background: var(--surface-2); }
details.book > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
details.book > summary b { font-weight: 600; flex: none; white-space: nowrap; }
details.book > summary .hint { min-width: 0; }
.book-ico { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); flex: none; }
details.book > .d-body { padding: 4px 16px 20px; }
.book-list { border-radius: 12px; border: 1px solid var(--hair); max-height: 300px; padding: 0 12px; }
.book-row { padding: 10px 0; }
.book-row:first-child { border-top: 0; }
.book-info b { font-weight: 600; font-size: 15px; }
.book-info small { font-size: 13px; }
.book-more { margin-top: 12px; }
.book-none { margin: 4px 0 0; }
.book-search { margin-bottom: 12px; }

/* ข้อหา: รายละเอียด ข้อควรระวัง ฎีกา */
.charge-dl { gap: 10px 20px; font-size: 15px; }
.charge-dl dt { font-size: 14px; font-weight: 500; }
.caution { display: flex; gap: 10px; align-items: flex-start; background: #fff7e6; color: #6b4300; border-radius: 12px; padding: 12px 16px; font-size: 14.5px; line-height: 1.6; margin-top: 20px; }
.caution > .ico { flex: none; margin-top: 3px; color: #c77700; }
.caution > div { min-width: 0; flex: 1; }
.caution.legal { background: var(--warn-bg); }
.caution.note-multi { margin: 0 auto 20px; background: var(--info-bg); color: #174e8a; }
.caution.note-multi > .ico { color: var(--info); }
.caution-act { margin-top: 10px; }
.d-sub { font-size: 13px; margin: 24px 0 8px; }
details.prec { margin-top: 20px; background: var(--surface-2); border-radius: 12px; }
.prec-i { font-size: 14.5px; }
.rel { gap: 4px; }

/* รายการข้อเท็จจริง / คำขอ (แก้ไขได้) */
.fact { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 16px; padding: 20px 0; border-top: 1px solid var(--hair); }
.fact:first-child { padding-top: 4px; }
.fact .no { align-self: start; margin-top: 8px; padding: 0 12px; line-height: 28px; height: 28px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: center; white-space: nowrap; }
.fact textarea { min-height: 96px; field-sizing: content; max-height: 360px; }
.fact .ctl { flex-direction: column; gap: 2px; }
.main .fact .btn.sm.icon { border-color: transparent; background: transparent; box-shadow: none; color: #5b6270; }
.main .fact .btn.sm.icon:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.main .fact .btn.sm.icon.danger { color: #b8473c; }
.main .fact .btn.sm.icon.danger:hover { background: var(--err-bg); color: var(--err); }
.main .fact .btn.sm.icon:disabled { background: transparent; border-color: transparent; color: #c6cad3; }

/* กล่องตัวแปร {{…}} และข้อท้ายคำฟ้อง */
.vars { margin-bottom: 16px; background: #fffaf0; border: 1px solid #f3e4bd; border-radius: var(--r-card); padding: 20px 28px 28px; }
.vars h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.vars .hint { margin-bottom: 20px; }
.panel.tail .tail-list { font-size: 14.5px; line-height: 1.75; padding-left: 1.8em; margin-top: 16px; }
.tail-opt { margin-top: 16px; }

/* หน้าคำร้องส่งหมาย */
.advice { border-radius: 14px; padding: 16px 20px; font-size: 15px; line-height: 1.6; border: 1px solid var(--hair); }
.advice > b { font-weight: 600; }
.advice p { margin: 6px 0 0; }
.advice.ok { background: var(--ok-bg); border-color: #c9e6d4; }
.advice.warn { background: var(--warn-bg); border-color: #f0dbb3; }
.svc-auto { margin: 24px 0 10px; }
.prose p { line-height: 1.75; }

/* ---------- แถบขั้นตอน / ถัดไป (ลอยติดล่าง) ---------- */
.wiz-nav { position: sticky; bottom: 16px; z-index: 12; margin-top: 32px; padding: 12px; background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%); border: 1px solid var(--hair-2); border-radius: var(--r-card); box-shadow: var(--sh-md); }
.wiz-btns { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.wiz-btns > :first-child { justify-self: start; }
.wiz-btns > :last-child { justify-self: end; }
.wiz-btns .btn { max-width: 100%; }
.wiz-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wiz-btns .btn.primary.is-locked { background: #f8c7a6; border-color: #f8c7a6; box-shadow: none; opacity: 1; cursor: not-allowed; }
.wiz-btns .btn.primary.is-locked:hover { background: #f8c7a6; border-color: #f8c7a6; }
.wiz-prog { display: grid; gap: 6px; justify-items: center; min-width: 120px; }
.wiz-prog-t { font-size: 13px; font-weight: 500; color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wiz-prog-bar { display: block; width: 100%; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.wiz-prog-bar i { display: block; height: 100%; border-radius: 99px; background: var(--blue); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.wiz-miss { background: var(--warn-bg); border: 0; color: #6b3d05; border-radius: 12px; padding: 12px 16px; margin: 0 0 12px; font-size: 14.5px; line-height: 1.5; }
.wiz-miss-h { display: flex; align-items: center; gap: 8px; }
.wiz-miss-h .ico { color: #c77700; flex: none; }
.wiz-miss ul { margin: 6px 0 0; padding-left: 1.4em; max-height: 120px; overflow: auto; }
.wiz-miss li + li { margin-top: 2px; }

/* ---------- จอแคบ ---------- */
@container main (max-width: 600px) {
  .panel { padding: 20px; }
  details.item > .d-body { padding: 20px; }
}
@container main (max-width: 440px) {
  .panel { padding: 16px; }
  details.item > .d-body { padding: 16px; }
  .fact { grid-template-columns: minmax(0, 1fr); }
  .fact .no { justify-self: start; margin-top: 0; }
  .fact .ctl { flex-direction: row; justify-content: flex-end; gap: 4px; }
}
@container main (max-width: 640px) {
  .f.s3, .f.s5 { grid-column: span 4; }
  .f.s7 { grid-column: span 8; }
}
@container main (max-width: 560px) {
  .f.s5, .f.s7 { grid-column: span 6; }
  .f.s3 { grid-column: span 4; }
}
@container main (max-width: 440px) {
  .f.s2, .f.s3, .f.s4 { grid-column: span 6; }
  .f.s5, .f.s6, .f.s7, .f.s8 { grid-column: span 12; }
  .f.s8 + .f.s4, .f.s7 + .f.s4, .f.s6 + .f.s4, .f.s8 + .f.s3 { grid-column: span 12; }
}@media (max-width: 1100px) {
  .main { padding: 32px 28px 120px; }
}
@media (max-width: 760px) {
  .main { padding: 20px var(--gutter, 16px) calc(24px + env(safe-area-inset-bottom, 0px)); }
  .main:has(> .wiz-nav) { padding-bottom: 0; }
  .main h2 { font-size: 23px; }
  .main .sub { margin-bottom: 20px; }
  .panel { border-radius: 14px; padding: 20px; margin-bottom: 12px; }
  .grid, .agrp { gap: 20px 14px; }
  .f { gap: 6px; }
  .f > span { margin-bottom: 2px; }
  .grp + .grp, .grid + .grp, .grid + .grid { margin-top: 24px; }
  .main .grid > .grp-t, .main .agrp > .grp-t { margin-top: 4px; margin-bottom: 2px; }
  .grid > .f.s8 + .f.s4, .grid > .f.s7 + .f.s4 { grid-column: span 12; }
  .attach-panel { border-radius: 14px; padding: 16px 14px; margin-bottom: 14px; }
  details.item > .d-body { padding: 20px 16px; }
  .sel-inline, .sel-grow { width: 100%; max-width: none; min-height: 44px; font-size: 16px; }
  .item-toolbar select { min-height: 44px; font-size: 16px; }
  .src-line a, .prec-i a { display: inline-flex; align-items: center; min-height: 44px; }
  details.more > summary { min-height: 44px; }
  details.more > summary .hint { display: none; }
  .toolbar > .btn { flex: 1 1 auto; }
  .wiz-nav { position: sticky; bottom: 0; margin: 24px calc(var(--gutter, 16px) * -1) 0; padding: 10px var(--gutter, 16px) calc(10px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); background: #fff; /* ทึบ — กันตัวหนังสือด้านหลังโผล่ทะลุแถบบน Safari */ }
  .wiz-btns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .wiz-prog { grid-column: 1 / -1; grid-row: 1; min-width: 0; }
  .wiz-prog-t { display: none; }
  .wiz-prog-bar { height: 3px; margin-bottom: 4px; }
  .wiz-btns .btn { min-height: 48px; justify-content: center; }
  .wiz-btns > span:empty { display: block; }
  .wiz-btns .btn .wiz-t { flex: 0 1 auto; }
  .wiz-miss { max-height: 108px; overflow-y: auto; scrollbar-width: thin; font-size: 13.5px; padding: 8px 12px; margin-bottom: 8px; }
  .wiz-miss ul { max-height: none; }
  /* มือถือ: รายการที่ยังขาดเรียงต่อกันเป็นแถว (ประหยัดที่ — แถบล่างเคยกินราวหนึ่งในสามของจอ) */
  .wiz-miss { font-size: 13px; padding: 6px 12px; }
  .wiz-miss-h { font-size: 13px; }
  .wiz-miss ul { display: flex; flex-wrap: wrap; gap: 0 14px; list-style: none; padding-left: 0; margin-top: 2px; max-height: 3.2em; overflow-y: auto; }
  .wiz-miss li { margin: 0; }
  .wiz-miss li + li { margin-top: 0; }
  .wiz-miss li::before { content: '• '; }
}
@media (prefers-reduced-motion: reduce) {
  .wiz-prog-bar i { transition: none; }
}

/* ค่านำหมายรวมหลายจำเลย (อ่านอย่างเดียว) */
.fee-sum { gap: 8px; }
.fee-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fee-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2, #f7f7f9); }
.fee-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 10px; background: var(--blue-soft, #fff1e8); color: var(--ink); font-weight: 600; }
.fee-total output { font-size: 20px; }
/* ---------- หลังยื่นฟ้อง (เลขคดี · ป้าย “ฟ้องแล้ว” · กลุ่มเอกสารหลังยื่นฟ้อง) ---------- */
.filed-chip { flex: none; display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px; margin-left: 4px; border-radius: 99px; background: var(--ok-bg); color: var(--ok); font-size: 13.5px; font-weight: 700; line-height: 1.4; white-space: nowrap; }
.filed-chip[hidden] { display: none; }
.nav-filed { display: flex; align-items: center; gap: 8px; margin: 6px 0 8px; padding: 8px 12px; border-radius: var(--r-ctl); background: var(--ok-bg); color: var(--ok); font-size: 14px; font-weight: 700; line-height: 1.35; }
.nav-filed .ico { flex: none; }
.nav-filed span { min-width: 0; overflow-wrap: anywhere; }
.panel.post-filing { border-color: var(--hair-2); border-left: 4px solid #c9ced8; }
.panel.post-filing.is-filed, .panel.post-docs { border-left: 4px solid var(--ok); }
.panel.post-filing > h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.panel.post-filing .pf-go { margin-top: 16px; gap: 8px; flex-wrap: wrap; }
.panel.post-docs > h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel.post-docs .doc-pick { margin-top: 12px; }
.wiz-miss.soft { background: var(--surface-3); color: var(--ink-2); }
.wiz-miss.soft .wiz-miss-h .ico { color: var(--muted); }
@media (max-width: 760px) {
  .topbar .filed-chip { display: none; }
  .panel.post-filing .pf-go .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- มือถือ (≤ 760px): เมนูคดีเป็นลิ้นชักแนวตั้ง เปิดด้วยปุ่ม 4 ขีดที่แถบบน ----------
   nav#steps อยู่ใน .work ตามเดิม แต่เป็น position:fixed ชิดซ้าย เลื่อนเข้า/ออกด้วย transform ; .work.navopen = เปิดอยู่ (ตั้งโดย js/navdrawer.js)
   ชั้น: แถบบน 20 → (ขณะเปิดถูกลดเหลือ 1 เพื่อให้พื้นหลังทึบคลุมแถบบนด้วย) · wiz-nav 12 · ตัวอย่างเต็มจอ 60 · พื้นหลังทึบ 65 · ลิ้นชัก 70 · toast 90 */
.nav-toggle, .steps-head, .steps-backdrop { display: none; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; margin: 0 0 0 -8px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .15s, color .15s; }
  .nav-toggle:active { background: var(--surface-3); }
  .nav-toggle[aria-expanded=true] { background: var(--blue-soft); color: var(--blue); }
  .nav-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
  .nav-toggle .ico { width: 24px; height: 24px; }
  .topbar:has(.nav-toggle) { transition: z-index 0s linear .3s; }
  /* ขณะลิ้นชักเปิด: ซ่อนแถบบนทั้งแถบ — Safari บน iPhone วาดแถบบน (sticky + backdrop-filter) ทับลิ้นชักแม้ z-index ต่ำกว่า ทำให้หัว “เมนูคดี” ถูกทับ/หาย */
  body:has(.work.navopen) .topbar { z-index: 1; visibility: hidden; transition-delay: 0s; }
  html:has(.work.navopen), body:has(.work.navopen) { overflow: hidden; }

  .work > .steps {
    position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); height: auto; min-height: 0;
    display: flex; flex-direction: column; padding: 0 0 calc(16px + env(safe-area-inset-bottom, 0px));
    background: #fff; border: 0; box-shadow: 10px 0 36px rgba(16, 24, 40, .2);
    overflow: hidden; /* ตัวลิ้นชักไม่เลื่อนเอง — รายการเลื่อนใน .steps-scroll (หัว “เมนูคดี” จึงอยู่นิ่งโดยไม่ต้องใช้ sticky ซึ่ง Safari บน iPhone วาดผิด/หายหลังปล่อยนิ้ว) */
    transform: translateX(-104%); visibility: hidden; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
  }
  .work > .steps > .steps-scroll { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding-bottom: 16px; }
  .work.navopen > .steps { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  .work > .steps-backdrop { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(16, 24, 40, .46); opacity: 0; visibility: hidden; -webkit-tap-highlight-color: transparent; transition: opacity .3s ease, visibility 0s linear .3s; }
  .work.navopen > .steps-backdrop { opacity: 1; visibility: visible; transition: opacity .3s ease, visibility 0s; }

  .steps-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 2; min-height: 60px; padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px calc(20px + env(safe-area-inset-left, 0px)); background: #fff; border-bottom: 1px solid var(--hair-2); }
  .steps-head b { font-size: 18px; font-weight: 700; letter-spacing: -.005em; color: var(--ink); }
  .steps-x { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .steps-x:active { background: var(--surface-3); }
  .steps-x:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

  .work > .steps .nav-group { margin: 0; padding: 0 calc(8px + env(safe-area-inset-right, 0px)) 4px calc(8px + env(safe-area-inset-left, 0px)); }
  .work > .steps .nav-group + .nav-group { border-top: 1px solid var(--hair); padding-top: 4px; }
  .work > .steps .nav-head { padding: 14px 12px 6px; font-size: 13.5px; }
  .work > .steps .nav-item { min-height: 52px; padding: 4px 12px; gap: 12px; border-radius: 14px; font-size: 16px; white-space: normal; background: transparent; }
  .work > .steps .nav-item:active { background: var(--surface-3); }
  .work > .steps .nav-item.on { background: var(--blue-soft); }
  .work > .steps .nav-ico { width: 28px; height: 28px; }
  .work > .steps .nav-ico .ico { width: 22px; height: 22px; }
  .work > .steps .nav-item .lock { margin-left: auto; }
  .work > .steps .nav-filed { margin: 12px 16px 4px; padding: 10px 12px; border-radius: 12px; white-space: normal; }
}

/* ---------- แท็บบัญชีพยาน ---------- */
/* ปุ่มเพิ่มพยานทุกปุ่มกว้าง/สูงเท่ากัน (กริดคอลัมน์เท่ากัน) · ช่อง “เพิ่มจากรายชื่อคู่ความ” ลงแถวถัดไป */
.toolbar.wit-add { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.toolbar.wit-add.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.toolbar.wit-add > .btn { width: 100%; min-width: 0; min-height: 44px; padding: 0 12px; justify-content: center; text-align: center; white-space: nowrap; }
.toolbar.wit-add > .wit-from { grid-column: span 2; width: 100%; min-width: 0; max-width: none; min-height: 44px; font-size: 15px; }
.toolbar.wit-add.n3 > .wit-from { grid-column: span 2; }
/* ประเภทพยาน: 3 ตัวเลือกกว้างเท่ากันเต็มความกว้าง */
.f.wit-kind > .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; align-self: stretch; }
.f.wit-kind > .seg label { width: 100%; min-width: 0; text-align: center; }
.sum-pos { flex: 0 1 auto; }
.wit-addr .wit-phone { margin-top: 16px; }
@media (max-width: 760px) {
  .toolbar.wit-add { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar.wit-add.n3 { grid-template-columns: minmax(0, 1fr); }
  .toolbar.wit-add > .btn { min-height: 48px; }
  .toolbar.wit-add > .wit-from, .toolbar.wit-add.n3 > .wit-from { grid-column: 1 / -1; min-height: 48px; font-size: 16px; }
  .panel > h3 .chk.sw { min-height: 44px; }
}
.wit-panel > h3 > .ico { flex: none; }
.wit-panel > h3 > .h-t { flex: 1 1 14em; min-width: 0; }
.wit-panel > h3 > .chk { flex: none; }
.wit-panel .rows .r-act .btn { min-width: 128px; justify-content: center; }
/* เลือกชั้นที่ใช้คำร้องขอหมายเรียกพยาน (ไต่สวนมูลฟ้อง / พิจารณา) — อยู่ระหว่างหัวกล่องกับคำอธิบาย */
.wit-panel > .wit-stage { margin: 6px 0 10px; }
@media (max-width: 760px) {
  .wit-panel > h3 > .grow { display: none; }
  .wit-panel > h3 > .chk { flex: 1 1 100%; }
  .main .wit-panel .rows .r-act { justify-self: stretch; }
  .wit-panel .rows .r-act .btn { width: 100%; min-height: 44px; }
  /* แถบบนของคดี: ปุ่มเมนูเพิ่มมา 1 ปุ่ม → ชื่อแบรนด์ย่อด้วย … แทนการล้นไปทับปุ่มด้านขวา */
  .topbar:has(.nav-toggle) .brand { overflow: hidden; margin-left: 0; padding-left: 4px; }
  .topbar:has(.nav-toggle) .brand-text { min-width: 0; overflow: hidden; }
  .topbar:has(.nav-toggle) .brand-text > span { overflow: hidden; text-overflow: ellipsis; }
}
.f.wit-kind > .seg label { padding: 0 6px; white-space: nowrap; }
/* QA: วิธีส่งหมายเรียก — 3 ตัวเลือกกว้างเท่ากันเต็มความกว้าง (ไม่ตกบรรทัด) */
.f.wit-deliver > .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; align-self: stretch; }
.f.wit-deliver > .seg label { width: 100%; min-width: 0; padding: 0 4px; text-align: center; white-space: normal; }
@media (max-width: 760px) { .f.wit-deliver > .seg label { font-size: 14px; } }

/* มือถือ: แถบบนของคดี (มีปุ่มเมนู 4 ขีด) — ลดขนาดตัวอักษรชื่อแบรนด์ให้เห็นฉบับเต็ม ไม่ตัดด้วย … */
@media (max-width: 760px) {
  .topbar:has(.nav-toggle) { gap: 2px; padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px)); }
  .topbar:has(.nav-toggle) .brand { gap: 5px; padding-left: 2px; overflow: visible; --brand-h: 22px; }
  .topbar:has(.nav-toggle) .brand-text { overflow: visible; min-width: max-content; }
  .topbar:has(.nav-toggle) .brand-text > span { overflow: visible; text-overflow: clip; }
  .topbar:has(.nav-toggle) .brand-text .lt-th { font-size: clamp(12px, 3.6vw, 14.5px); letter-spacing: -.015em; }
  .topbar:has(.nav-toggle) .brand-text .lt-en { font-size: clamp(10px, 2.9vw, 11.5px); letter-spacing: 0; }
  .topbar:has(.nav-toggle) .grow { flex: 1 1 0; min-width: 0; } /* ดันกลุ่มปุ่มขวา (สถานะ/ตัวอย่าง/คดีทั้งหมด) ชิดขอบขวาตามความกว้างจอ */
  .topbar:has(.nav-toggle) > .btn, .topbar:has(.nav-toggle) > .btn:has(> .tb-i), .topbar:has(.nav-toggle) .ready-chip { min-width: 40px; padding: 0 8px; }
}
/* คอม/แท็บเล็ต (≥761px): แถบ "ขั้นที่ n จาก N" + ปุ่มก่อนหน้า/ถัดไป ตรึงอยู่ล่างสุดของคอลัมน์ฟอร์มเสมอ (เต็มความกว้าง ไม่ลอย ไม่มีเงา)
   — คอลัมน์ฟอร์มเป็น flex แนวตั้ง แถบใช้ margin-top:auto จึงอยู่ล่างสุดทั้งตอนเนื้อหาสั้น (ดันลงล่าง) และยาว (sticky ติดขอบล่าง) */
@media (min-width: 761px) {
  .main:has(> .wiz-nav) { display: flex; flex-direction: column; padding-bottom: 0; }
  .main:has(> .wiz-nav) > * { flex: none; width: 100%; box-sizing: border-box; }
  .main:has(> .wiz-nav) > .wiz-nav {
    position: sticky; bottom: 0; z-index: 12; margin: auto -40px 0; width: calc(100% + 80px); max-width: none;
    padding: 12px max(40px, calc((100% - 800px) / 2)); border-width: 1px 0 0; border-radius: 0;
    background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none;
  }
  .main:has(> .wiz-nav) > .wiz-nav::before { content: ''; display: block; height: 32px; margin: -44px -40px 12px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg, #f5f5f7)); opacity: 0; }
  .main:has(> .wiz-nav) > :nth-last-child(2) { margin-bottom: 32px; }
}

/* ---------- จัดวางตามข้อสังเกตหน้าจอ ---------- */
/* หน้าคู่ความ: ปุ่ม “เพิ่มโจทก์” กับ “เพิ่มจำเลย” กว้างเท่ากัน (ครึ่งต่อครึ่ง) · ปุ่มสลับอยู่แถวล่างเต็มความกว้าง */
.toolbar:has(> [data-act="addParty"]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.toolbar:has(> [data-act="addParty"]) > .grow { display: none; }
.toolbar:has(> [data-act="addParty"]) > .btn { width: 100%; min-width: 0; justify-content: center; text-align: center; }
.toolbar:has(> [data-act="addParty"]) > [data-act="swapRoles"] { grid-column: 1 / -1; }

/* การ์ดคู่ความ/จำเลย: บทบาท + ประเภทบุคคล แบ่งครึ่งเท่ากันพอดีความกว้าง ตัวหนังสือกึ่งกลาง ·
   “เลือกจากสมุดรายชื่อ” + “บันทึกลงสมุดรายชื่อ” อยู่แถวเดียวกัน · ปุ่มลบเต็มแถวล่างสุด */
.item-toolbar:has(> .tb-book) > .grow { display: none; }
.item-toolbar:has(> .tb-book) > label.f { flex: 1 1 calc(50% - 4px); min-width: 0; }
.item-toolbar:has(> .tb-book) > label.f > select { width: 100%; min-width: 0; padding-inline: 26px; text-align: center; text-align-last: center; background-position: right 10px center; }
.tb-book { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; min-width: 0; }
.tb-book > select { flex: 1 1 0; width: auto; min-width: 0; text-overflow: ellipsis; }
.tb-book > .btn { flex: none; white-space: nowrap; }
.item-toolbar:has(> .tb-book) > .btn.danger { flex: 1 1 100%; justify-content: center; }

/* หน้าคำร้อง: เลือกแม่แบบ = ช่องเดียวเต็มแถว · ปุ่ม “เพิ่มจากแม่แบบ” กับ “คำร้องเปล่า” แถวเดียวกัน กว้างครึ่งต่อครึ่ง */
.row.motion-add { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.row.motion-add > select { grid-column: 1 / -1; width: 100%; max-width: none; min-width: 0; flex: none; }
.row.motion-add > .btn { width: 100%; min-width: 0; justify-content: center; text-align: center; }

/* ช่องวันที่/เวลา: ตัวเลขชิดซ้ายและอยู่กลางช่องในแนวตั้งเหมือนช่องข้อความ (กัน Safari/มือถือที่ค่าวันที่ลอยกลางหรือสูงต่ำกว่าช่องอื่น) */
input[type=date], input[type=time] { line-height: 1.4; text-align: left; font-variant-numeric: tabular-nums; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.4em; }
input[type=date]::-webkit-datetime-edit, input[type=time]::-webkit-datetime-edit { padding: 0; }

/* หน้าตำแหน่งตัวหนังสือ & ตราครุฑ: กลุ่ม (หน้ากระดาษ · ตัวอักษร · ตราครุฑ …) เรียงแนวตั้ง แถวละหนึ่งกลุ่ม เต็มความกว้าง */
.fit .gtabs { display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
.fit .gtabs button { width: 100%; justify-content: flex-start; border-radius: 10px; padding: 0 16px; }

/* ===== QA ฝั่งโจทก์ (case editor): แถววิธีส่งหมายรายจำเลย · ปุ่มถัดไปที่ถูกล็อก · ป้ายปุ่มขั้นตอนบนมือถือ ===== */
/* แถววิธีส่งหมายรายจำเลย: ชื่อ / ตัวเลือก / หมายเหตุ เรียงเป็นแถวเดียวบนจอกว้าง และซ้อนเป็นคอลัมน์เมื่อแคบ (ชื่อยาวไม่บีบช่องเลือก) */
.fee-list li.fee-row { flex-wrap: wrap; align-items: center; row-gap: 6px; }
.fee-row .fee-who { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.fee-row select { flex: 0 1 260px; min-width: 0; max-width: 100%; }
.fee-row .hint { flex: 1 1 100%; margin: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .fee-row .fee-who, .fee-row select { flex: 1 1 100%; }
  .fee-row select { min-height: 44px; font-size: 16px; }
}
/* ค่านำหมายเจ้าพนักงาน: ปุ่มคำนวณจากที่อยู่ + ช่องตัวเลข + หมายเหตุศาล */
.fee-off { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.fee-off .fee-amt { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.fee-off .fee-amt input { width: 130px; max-width: 100%; }
.fee-off .hint { flex: 1 1 100%; margin: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) { .fee-off .btn, .fee-off .fee-amt input { min-height: 44px; font-size: 16px; } .fee-off .fee-amt { flex: 1 1 140px; } }
/* ปุ่ม “ถัดไป” ที่ยังไปต่อไม่ได้ (กรอกไม่ครบ): ตัวหนังสือต้องอ่านออก (เดิมขาวบนฟ้าอ่อน ตัดกันเพียง 1.8:1) */
.wiz-btns .btn.primary.is-locked, .wiz-btns .btn.primary.is-locked:hover { background: #fde9dc; border-color: #f4bf9b; color: #8a3f12; }
/* ลิงก์แหล่งอ้างอิงในหน้าคำฟ้อง: น้ำเงินเข้มขึ้นเล็กน้อยให้ตัดกับพื้นเทาได้ ≥ 4.5:1 */
.src-line a { color: #b9480c; }
/* มือถือ: ป้ายปุ่มขั้นตอนยาว (เช่น “คำให้การ & สัญญา”) ขึ้นบรรทัดใหม่ได้แทนที่จะถูกตัดเป็น … */
@media (max-width: 760px) {
  .wiz-btns .btn .wiz-t { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
}

/* ---------- ลำดับเอกสารในชุด (หน้าออกเอกสาร): รายการชนิดเอกสาร + ปุ่มเลื่อนขึ้น/ลง ---------- */
.doc-order > h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.do-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.do-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2, #f7f7f9); }
.do-n { flex: none; min-width: 1.6em; font-size: 13px; font-weight: 700; color: #5f6674; font-variant-numeric: tabular-nums; }
.do-t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.do-t small { color: var(--muted); }
.do-act { flex: none; display: flex; gap: 4px; }
.do-act .btn.icon { min-width: 36px; min-height: 36px; }
@media (max-width: 760px) { .do-act .btn.icon { min-width: 44px; min-height: 44px; } }

/* ===== มือถือ: ปุ่มในพื้นที่ทำงานกว้างเต็มแถว (ปุ่มละแถว ตัวหนังสือกึ่งกลาง สูง ≥ 46px) =====
   ครอบคลุมแถบปุ่ม (.toolbar / .item-toolbar / .btn-group / .row) ปุ่มไปหน้าอื่นในการ์ดเลขคดี (.pf-go) ปุ่มดาวน์โหลด (.dl-main)
   และปุ่ม “ดู PDF” ท้ายรายการเอกสาร (.docrow) — ยกเว้นกลุ่มที่จัดเป็นตารางสองคอลัมน์ไว้แล้ว (เพิ่มโจทก์/จำเลย · เพิ่มพยาน · แม่แบบคำร้อง)
   ปุ่มไอคอนล้วน (.btn.icon) ปุ่มในหัวการ์ดสรุป (.sum-act) และแถบปุ่มถัดไป/ย้อนกลับ (.wiz-btns) ซึ่งมีกฎของตัวเอง */
@media (max-width: 760px) {
  .main :is(.toolbar, .item-toolbar, .btn-group, .row, .pf-go, .dl-main .btn-group, .fee-off) > .btn:not(.icon),
  .main .dl-main > .btn {
    flex: 1 1 100%; width: 100%; min-width: 0; max-width: none; min-height: 46px; padding-inline: 14px; justify-content: center; text-align: center; white-space: normal; line-height: 1.3;
  }
  .main :is(.toolbar, .item-toolbar, .btn-group, .row) > .grow { display: none; }
  .main .dl-main .btn-group { flex-direction: column; align-items: stretch; }
  /* รายการเอกสารในหน้าออกเอกสาร (.docrow) ให้คงแถวเดียวกระชับ ไม่ดันปุ่มแตกแถวเต็มจอ */
  .main .docrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    flex-wrap: nowrap;
  }
  .main .docrow > .btn {
    flex: none !important;
    width: auto !important;
    min-width: 72px;
    min-height: 38px;
    padding: 6px 14px;
    margin-top: 0 !important;
    white-space: nowrap;
  }
  /* รายการเอกสาร / สถานะ (.rows / .rows-req): จัดแนวนอน ปุ่มอยู่ขวา ไม่แตกแถวกว้าง 100% */
  .main .rows > li,
  .main .rows-req > li,
  .main .post-docs .rows > li {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .main .rows > li > .r-act,
  .main .rows-req > li > .r-act {
    flex-shrink: 0;
    margin-left: auto;
    justify-self: end;
    display: flex;
  }
  .main .rows > li > .r-act > .btn,
  .main .rows-req > li > .r-act > .btn {
    flex: none;
    width: auto;
    min-height: 40px;
    padding: 0 16px;
    white-space: nowrap;
    justify-content: center;
  }
  /* กลุ่มที่เป็นตารางสองคอลัมน์: ปุ่มเต็มช่องของตัวเอง (ไม่ใช่เต็มแถว) */
  .main :is(.toolbar:has(> [data-act="addParty"]), .toolbar.wit-add, .row.motion-add) > .btn { flex: initial; }
  .main .toolbar.wit-add:not(.n3) > .btn { min-height: 48px; }
}