/* ============================================================
   หลังบ้านระบบร่างคำฟ้อง — โครงหน้าพื้นที่ทำงานคดี (โทเคน/ปุ่ม/ช่องกรอก/ป้าย/แถบบน อยู่ใน admin-base.css)
   หลัก: พื้นหลังต่างระดับแทนเส้นขอบ · กริด 8px · หัวข้อสม่ำเสมอ · พับส่วนที่ไม่จำเป็น
   (toast / banner / popup แจ้งเตือน อยู่ใน notify.css)
   ============================================================ */
:root { /* สีหลัก (ชื่อเดิมคงไว้เพราะไฟล์อื่นอ้างอิง) */ --navy: #1d1d1f; --navy-2: #f26b1d; --gold: #f26b1d; --gold-soft: #fff1e8; --bg: #f5f5f7; --card: #ffffff; --ink: #1d2433; --muted: #5a6477; --line: #d5d7de; --ok: #1a7a49; --warn: #94560a; --err: #b42318; --info: #1d5fa8; --r: 12px; --shadow: none; /* ชั้นพื้นผิว */ --surface-2: #f7f7f9; --surface-3: #efeff3; --hair: #ececf0; --blue: #f26b1d; --blue-soft: #fff1e8; --ok-bg: #e6f4ec; --warn-bg: #fdf1dc; --err-bg: #fdeae7; --info-bg: #e8f1fb; --focus: 0 0 0 3px rgba(242, 107, 29, .22); --nav-w: 224px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-y: scroll; scrollbar-gutter: stable; }
body { font-family: var(--font); font-size: 16px; line-height: 1.6; text-rendering: optimizeLegibility; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--surface-3); border-radius: 4px; padding: 0 5px; font-size: .92em; }
a { color: var(--blue); }
/* ---------- โครง 3 คอลัมน์ ---------- */
.work { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr) 40%; min-height: calc(100vh - 52px); }
.work.nopreview { grid-template-columns: var(--nav-w) 1fr; }
.steps { background: #ebebef; padding: 16px 12px 32px; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.main { padding: 32px 32px 96px; min-width: 0; container: main / inline-size; }
.main>* { max-width: 800px; margin-left: auto; margin-right: auto; }
.main h2 { margin: 0 0 4px; font-size: 24px; line-height: 1.3; letter-spacing: -.01em; color: var(--navy); }
.main .sub { color: var(--muted); font-size: 15px; margin: 0 0 24px; max-width: 68ch; }
.main h3.part { font-size: 19px; line-height: 1.35; margin: 8px 0 4px; color: var(--navy); }
.main h3.part+.sub { margin-bottom: 16px; }
.part-sep { border: 0; border-top: 1px solid #e3e3e8; margin: 40px auto 32px; }
.preview { background: #d9d9de; position: relative; min-height: 0; display: flex; flex-direction: column; min-width: 0; }
/* กรอบเลื่อนของตัวอย่าง: แถบเลื่อนแนวตั้งแสดงเสมอ (ไม่ใช่ auto) → ความกว้างใช้งานคงที่ไม่ว่ามี 1 หรือ 3 แผ่น ขนาด “พอดี” จึงเท่ากันทุกแท็บ */
.pv-scroll { flex: 1 1 0; min-height: 0; overflow-x: auto; overflow-y: scroll; padding: 16px 0; overflow-anchor: none; overscroll-behavior: contain; }
.pv-inner { transform-origin: top left; }
/* ---------- จอคอมพิวเตอร์/แท็บเล็ต (> 760px): พื้นที่ทำงานพอดีจอ หน้าเว็บไม่เลื่อนเอง ----------
   เมนูซ้าย · ฟอร์มกลาง · ตัวอย่างขวา เลื่อนในกรอบของตัวเอง → ไม่มีแถบเลื่อนของหน้าเว็บที่โผล่/หายตามความยาวฟอร์ม
   ความกว้างทุกคอลัมน์ (และขนาดแผ่น A4 ในตัวอย่าง) จึงเท่ากันทุกแท็บโดยโครงสร้าง ไม่ต้องพึ่ง scrollbar-gutter */
@media (min-width: 761px) {
  html:has(#app > .work) { overflow: hidden; scrollbar-gutter: auto; scroll-behavior: auto; }
  body:has(#app > .work) { overflow: hidden; }
  #app:has(> .work) { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  #app:has(> .work) > :not(.work) { flex: none; }
  #app > .work { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .work > .steps { scrollbar-gutter: stable; }
  .work > .main { min-height: 0; overflow-x: hidden; overflow-y: scroll; overscroll-behavior: contain; }
}
/* ---------- เมนูซ้าย ---------- */
.nav-group { margin-bottom: 8px; }
.nav-head { flex-wrap: wrap; }
.nav-label { flex: 1; min-width: 0; line-height: 1.3; }
/* ---------- การ์ด / หัวข้อ ---------- */
.panel>h3 .grow { flex: 1; }
.panel>.panel-note { margin: -8px 0 16px; }
.sec-h { margin: 32px 0 8px; }
.sec-h .grow { flex: 1; }
.sec-h .cnt { font-weight: 500; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
/* กลุ่มช่องย่อย: หัวข้อเล็ก + grid */
.grp+.grp, .grp+.more, .grid+.grp, .grid+.grid, .panel>.grp~.btn-group { margin-top: 24px; }
.grp-t { grid-column: 1 / -1; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: #6b7280; margin: 0 0 8px; }
.grid>.grp-t, .agrp>.grp-t { margin-bottom: -4px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.agrp { grid-column: 1 / -1; display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-top: 8px; }
.grid>.more, .grid>.grp, .grid>.hint-row { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 4px; grid-column: span 6; min-width: 0; }
.f.s2 { grid-column: span 3; }
.f.s3 { grid-column: span 3; }
.f.s4 { grid-column: span 4; }
.f.s5 { grid-column: span 5; }
.f.s6 { grid-column: span 6; }
.f.s7 { grid-column: span 7; }
.f.s8 { grid-column: span 8; }
.f.s12 { grid-column: span 12; }
.f.spacer { display: none; }
.f>span em { color: var(--err); font-style: normal; }
.f>.hint { margin-top: 0; }
.f>.hint:has(> .idchk:empty) { display: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dt-row { display: grid; grid-template-columns: 80px minmax(120px, 1fr) 104px; gap: 8px; }
.dt-row>* { min-width: 0; }
/* ---------- การ์ดพับ/ขยาย (รายการ) ---------- */
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }
details.item { background: var(--card); border-radius: 12px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .05); margin-bottom: 8px; }
details.item>summary { display: flex; align-items: center; gap: 8px; padding: 8px 16px; min-height: 56px; list-style: none; border-radius: 12px; }
details.item>summary:hover { background: var(--surface-2); }
details.item[open]>summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
details.item>summary::before, details.more>summary::before, details.book>summary::before, details.prec>summary::before { content: ''; width: 7px; height: 7px; flex: none; border-right: 2px solid #8a909c; border-bottom: 2px solid #8a909c; transform: rotate(-45deg); margin: 0 6px 0 2px; transition: transform .15s; }
details[open]>summary::before { transform: rotate(45deg); }
details.item>.d-body { border-top: 1px solid var(--hair); padding: 24px 24px 24px; }
.sum-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; } /* ยาวเกินจอ = ขึ้นบรรทัดใหม่ ไม่ตัดด้วย … */
.sum-title { font-weight: 600; white-space: nowrap; flex: none; }
.sum-name { font-weight: 500; min-width: 0; white-space: normal; overflow-wrap: anywhere; flex: 1 1 12em; }
.sum-name em { font-style: normal; color: #6b7280; font-weight: 400; }
.sum-meta { color: var(--muted); font-size: 13.5px; min-width: 0; white-space: normal; overflow-wrap: anywhere; flex: 0 1 auto; }
.sum-badges { flex: none; }
.sum-main.wrap { flex-wrap: wrap; }
.sum-main.wrap .sum-name { white-space: normal; flex: 1 1 12em; }
.sum-main .pill { flex: none; }
.sum-main .pill:last-child { margin-left: auto; }
.sum-act { display: flex; gap: 4px; flex: none; align-items: center; }
.role-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
.role-dot.defendant { background: #d9473a; }
.item-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; }
.item-toolbar .grow { flex: 1; }
.item-toolbar select { width: auto; min-width: 128px; min-height: 36px; font-size: 14.5px; }
.item-toolbar .f { grid-column: auto; }
/* ลิงก์พับ “ข้อมูลเพิ่มเติม” */
details.more { margin-top: 24px; }
details.more>summary { display: inline-flex; align-items: center; gap: 4px; list-style: none; border-radius: 6px; min-height: 32px; padding: 0 4px; margin-left: -4px; }
.more-t { font-size: 14px; font-weight: 600; color: var(--blue); }
details.more>summary .hint { margin-left: 8px; }
details.more>.d-body { margin-top: 16px; }
.grid>details.more { margin-top: 8px; }
/* ---------- สมุดรายชื่อ ---------- */
details.book { background: var(--card); border-radius: 12px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .05); margin-bottom: 24px; }
details.book>summary { display: flex; gap: 8px; align-items: center; list-style: none; padding: 12px 16px; min-height: 48px; border-radius: 12px; }
details.book>summary:hover { background: var(--surface-2); }
details.book>.d-body { padding: 0 16px 16px; }
.book-search { margin: 0 0 8px; }
.book-list { display: grid; gap: 0; max-height: 280px; overflow: auto; }
.book-row { display: flex; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--hair); flex-wrap: wrap; }
.book-info { display: grid; min-width: 0; }
.book-info small { color: var(--muted); }
.book-act { display: flex; gap: 4px; flex-wrap: wrap; }
/* ---------- ข้อหา ---------- */
.ctag { background: var(--surface-3); color: #3f4654; border-radius: 6px; padding: 0 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sum-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.charge-dl { display: grid; grid-template-columns: 8.5em 1fr; gap: 8px 16px; margin: 0 0 16px; font-size: 15px; }
.charge-dl dt { color: var(--muted); }
.charge-dl dd { margin: 0; overflow-wrap: anywhere; }
.rel { display: grid; gap: 8px; margin-top: 8px; }
.caution { background: #fff6e0; border-radius: 8px; padding: 8px 12px; font-size: 14.5px; margin-top: 16px; color: #5c3a00; }
.caution.legal { background: var(--warn-bg); }
.d-sub { font-size: 13px; font-weight: 600; color: #6b7280; margin: 24px 0 0; }
details.prec { margin-top: 16px; background: var(--surface-2); border-radius: 8px; padding: 0 12px; }
details.prec>summary { display: flex; align-items: center; min-height: 40px; font-weight: 600; font-size: 14.5px; list-style: none; border-radius: 8px; }
details.prec[open] { padding-bottom: 8px; }
.prec-i { padding: 8px 0; border-top: 1px solid var(--hair); margin-top: 8px; font-size: 14.5px; }
/* ---------- ข้อเท็จจริง / คำขอ (รายการแก้ไขได้) ---------- */
.fact:first-child { border-top: 0; padding-top: 0; }
/* ---------- ตรวจสอบและออกเอกสาร ---------- */
.status-bar { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-radius: 12px; margin-bottom: 16px; background: var(--ok-bg); color: #0f5132; }
.status-bar.err { background: var(--err-bg); color: #7a1c13; }
.status-bar.warn { background: var(--warn-bg); color: #6b3d05; }
.status-bar .big { font-size: 17px; font-weight: 600; line-height: 1.35; }
.status-bar .hint { color: inherit; opacity: .85; }
.st-ico { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; background: var(--surface-3); color: #6b7280; }
.st-ico.ok { background: var(--ok-bg); color: var(--ok); }
.st-ico.warn { background: var(--warn-bg); color: var(--warn); }
.st-ico.err { background: var(--err-bg); color: var(--err); }
.st-ico.info { background: var(--info-bg); color: var(--info); }
.rows { list-style: none; padding: 0; margin: 0; }
.rows>li { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--hair); min-height: 56px; }
.rows>li:first-child { border-top: 0; padding-top: 0; }
.rows>li:last-child { padding-bottom: 0; }
.rows .r-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rows .r-note { display: block; font-size: 13px; color: var(--muted); }
.rows .r-act { flex: none; }
.iss-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #6b7280; margin: 24px 0 8px; }
.iss-h:first-of-type { margin-top: 0; }
details.iss-fold { margin-top: 24px; }
details.iss-fold>summary { display: flex; align-items: center; gap: 4px; list-style: none; min-height: 32px; font-size: 13px; font-weight: 600; color: #6b7280; border-radius: 6px; }
details.iss-fold>summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid #8a909c; border-bottom: 2px solid #8a909c; transform: rotate(-45deg); margin: 0 6px 0 2px; transition: transform .15s; }
details.iss-fold[open]>summary::before { transform: rotate(45deg); }
details.iss-fold>.rows { margin-top: 8px; }
.doc-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 24px; }
.doc-pick .chk { padding: 4px 0; }
.dl-main { padding: 16px; background: var(--surface-2); border-radius: 12px; margin-bottom: 24px; }
.docrow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--hair); flex-wrap: wrap; }
.docrow:first-child { border-top: 0; }
.docrow .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dl-sub { font-size: 13px; font-weight: 600; color: #6b7280; margin: 0 0 8px; }
/* ---------- อื่น ๆ ---------- */
table.simple { border-collapse: collapse; width: 100%; font-size: 15px; }
table.simple th { text-align: left; font-size: 13px; font-weight: 600; color: #6b7280; padding: 0 8px 8px; }
table.simple td { border-top: 1px solid var(--hair); padding: 12px 8px; text-align: left; vertical-align: middle; }
.tbl-wrap { overflow-x: auto; }
.ref-item { padding: 16px 0; border-top: 1px solid var(--hair); }
.ref-item:first-child { border-top: 0; padding-top: 0; }
.ref-item>div { margin-top: 4px; }
.prose p { margin: 0 0 .8em; line-height: 1.7; }
.prose mark, mark { background: #fff2a8; border-radius: 3px; padding: 0 3px; }
.savebar { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 72%, transparent); padding: 16px 0 8px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.advice { border-radius: 12px; padding: 16px; background: var(--surface-2); font-size: 15px; }
.advice p { margin: 4px 0 0; color: #3f4654; }
.advice.ok { background: var(--ok-bg); }
.advice.warn { background: var(--warn-bg); }
.idok { font-size: 13px; }
.idok.ok { color: var(--ok); }
.idok.bad { color: var(--err); }
em.own { font-style: normal; font-size: 12px; background: var(--blue-soft); color: var(--blue); border-radius: 99px; padding: 0 8px; margin-left: 4px; }
/* หน้าแก้ตำแหน่ง/ตราครุฑ */
.lay-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.lay-row { display: grid; gap: 4px; align-content: start; }
.chk.lay-row { display: flex; }
.lay-lab { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 14px; }
.lay-in { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.lay-in input[type=number] { width: 80px; min-height: 32px; padding: 0 8px; text-align: right; }
.lay-in i { font-style: normal; color: var(--muted); font-size: 13px; min-width: 2.4em; }
.lay-row input[type=range] { width: 100%; accent-color: var(--blue); }
.presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.presets .hint { margin-right: 4px; }
.lay-reset { margin-left: auto; }
.page.lay-flash { outline: 2px solid rgba(242, 107, 29, .35); outline-offset: -2px; transition: outline-color .3s; }
@media (min-width: 900px) {
  /* ความกว้างเมนู/ตัวอย่างต้องเท่ากับทุกหน้า (var(--nav-w) · 40%) — ห้ามหด/ขยายเมื่อสลับหน้า; หน้านี้ต่างแค่ “เปิดแผงตัวอย่างเสมอ” บนจอแคบ */
  .work.live { grid-template-columns: var(--nav-w) minmax(0, 1fr) 40%; }
  .work.live .preview { display: flex; position: relative; inset: auto; width: auto; box-shadow: none; z-index: 1; }
  /* ปิดแผงตัวอย่าง / เปิดเป็นแผงทับ → ไม่เหลือคอลัมน์ว่างที่ทำให้ฟอร์มแคบกว่าหน้าอื่น */
  .work.live.nopreview, .work.live.showpv { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
}
/* ---------- หน้า “ตั้งค่า & แม่แบบ” ---------- */
.main:has(> .fit) { padding-top: 32px; padding-bottom: 96px; }
.fit { min-height: 420px; display: flex; flex-direction: column; }
.fit-head { flex: none; }
.fit-body { flex: 1; padding: 4px 0 8px; border-radius: 12px; }
.fit-body:focus-visible { outline: 2px solid var(--blue); outline-offset: 0; }
.fit-foot { flex: none; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 0 0; }
.fit .main h2, .fit h2 { font-size: 21px; }
.fit h2 { margin-bottom: 0; }
.fit .sub { margin: 0 0 12px; font-size: 14px; }
.fit .toolbar { margin-bottom: 12px; }
.lay-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .05); padding: 8px 12px; margin-bottom: 12px; }
.lay-bar .grow { flex: 1; }
.lay-form { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #4b5563; font-weight: 500; }
.lay-form select { width: auto; min-height: 34px; font-size: 14.5px; }
.lay-lines { display: grid; }
.lay-line { display: grid; grid-template-columns: minmax(120px, 1.3fr) minmax(100px, 1.4fr) auto 32px; gap: 4px 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--hair); }
.lay-line:first-child { border-top: 0; }
.lay-line.chk-line { display: flex; }
.lay-name { font-size: 14.5px; line-height: 1.35; }
.lay-line .presets { grid-column: 2 / -1; margin: 0; }
.lay-in input[type=number] { width: 76px; }
.info[data-tip] { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 6px; border-radius: 50%; background: var(--surface-3); color: #5b6270; font-size: 11px; cursor: help; position: relative; vertical-align: middle; }
.info[data-tip]:hover::after, .info[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: -8px; bottom: calc(100% + 6px); width: max-content; max-width: 260px; background: #1c2330; color: #fff; font-size: 13px; line-height: 1.45; padding: 6px 10px; border-radius: 8px; z-index: 30; white-space: normal; text-align: left; font-style: normal; font-weight: 400; }
.fit-body>.panel { padding: 16px 20px; }
.fit table.simple td { padding: 6px 8px; }
.grow-r { margin-left: auto; }
.ft-item { padding: 8px 0; border-top: 1px solid var(--hair); }
.ft-item:first-child { border-top: 0; padding-top: 0; }
.ft-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.ft-h label { font-size: 13px; font-weight: 600; color: #3f4654; }
.ft-item .pill, .ft-item .link-btn { display: none; }
.ft-item[data-mod] .pill, .ft-item[data-mod] .link-btn { display: inline-flex; }
.ft-item textarea { min-height: 56px; max-height: 240px; field-sizing: content; }
.ft-grp { grid-column: auto; }
.ft-grp select { width: auto; min-width: 200px; max-width: 100%; min-height: 36px; font-size: 14.5px; }
.nowrap { white-space: nowrap; }
table.simple tr.used td { background: #f5f9ff; }
/* ตัวช่วยเล็ก ๆ */
.f>.seg { align-self: flex-start; }
.grp>.agrp { margin-top: 0; }
.grp.gap-top { margin-top: 24px; }
.panel>.hint:last-child { margin-bottom: 0; }
.presets .btn[aria-pressed=true] { background: var(--blue-soft); color: var(--blue); border-color: #b9d6f5; font-weight: 600; }
.panel>h3 .btn.sm { font-weight: 500; }
/* ---------- เข้าสู่ระบบ / เชื่อมต่อไม่ได้ (หน้าโหลดอยู่ที่ css/loading.css) ---------- */
.conn-fail { min-height: 60vh; display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.conn-fail p { margin: 0; max-width: 520px; }
[hidden] { display: none !important; }
@media print {
  body * { visibility: hidden; }
}
/* ---------- Responsive ---------- */
/* ฟอร์มปรับตามความกว้างของคอลัมน์กลางจริง (container query) */
@container main (max-width: 560px) {
  .grid, .agrp { gap: 20px 14px; }
  .f { gap: 6px; }
  .f > span { margin-bottom: 2px; }
  .f.s5 { grid-column: span 6; }
  .f.s7 { grid-column: span 6; }
  .dt-row { grid-template-columns: 72px minmax(0, 1fr) 96px; }
}
@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; }
  .panel { padding: 16px; }
  details.item>.d-body { padding: 16px; }
  .charge-dl { grid-template-columns: 1fr; gap: 0; }
  .charge-dl dd { margin-bottom: 8px; }
  .fact { grid-template-columns: minmax(0, 1fr) auto; }
  .fact .no { grid-column: 1 / -1; text-align: left; padding-top: 0; }
}
@media (max-width: 1280px) {
  :root { --nav-w: 208px; }
  .work { grid-template-columns: var(--nav-w) 1fr; }
  .preview { display: none; }
  .work.showpv .preview { display: flex; position: fixed; inset: 52px 0 0 auto; width: min(560px, 100%); z-index: 15; box-shadow: -8px 0 30px #0004; }
}
@media (max-width: 1100px) {
  :root { --nav-w: 192px; }
  .main { padding: 24px 24px 80px; }
}
@container main (max-width: 520px) {
  .lay-line { grid-template-columns: minmax(0, 1fr) auto 32px; }
  .lay-name { grid-column: 1 / -1; }
  .lay-line .presets { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .work { grid-template-columns: 1fr; }
  /* เมนูขั้นตอนบนมือถือเป็นลิ้นชักแนวตั้ง — ดูกฎ “เมนูคดี” ท้าย admin-work.css */
  .main { padding: 16px 16px 80px; }
  .main h2 { font-size: 21px; }
  .work.live { grid-template-columns: 1fr; }
  .work.live:not(.showpv) .preview { display: none; } /* เปิดแผงทับด้วยปุ่ม “ตัวอย่างเอกสาร” ได้เหมือนหน้าอื่น */
  .grid, .agrp { gap: 20px 14px; }
  .f { gap: 6px; }
  .f > span { margin-bottom: 2px; }
  .grp + .grp, .grid + .grp, .grid + .grid { margin-top: 24px; }
  .rows>li { flex-wrap: wrap; gap: 8px 12px; }
  .rows .r-act { margin-left: 36px; }
  .status-bar { padding: 16px; }
  .sum-main { flex-wrap: wrap; }
  .sum-name { white-space: normal; }
  .sum-main .pill:last-child { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.f .lbl { font-size: 13.5px; color: var(--muted); font-weight: 500; }
/* ---------- การเปลี่ยนหน้าแบบนุ่ม ๆ (ไม่ให้ข้อมูลโผล่พรึบ) ---------- */
@keyframes enter-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.main.enter>*, .home.enter>* { animation: enter-up .42s cubic-bezier(.2, .8, .2, 1) both; }
.main.enter> :nth-child(2), .home.enter> :nth-child(2) { animation-delay: .04s; }
.main.enter> :nth-child(3), .home.enter> :nth-child(3) { animation-delay: .08s; }
.main.enter> :nth-child(4), .home.enter> :nth-child(4) { animation-delay: .12s; }
.main.enter> :nth-child(5), .home.enter> :nth-child(5) { animation-delay: .16s; }
.main.enter> :nth-child(n+6), .home.enter> :nth-child(n+6) { animation-delay: .2s; }
.pv-inner.pv-swap { animation: pv-fade .22s ease both; }
@keyframes pv-fade { from { opacity: .25; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .main.enter>*, .home.enter>*, .home.enter .cards>.card, .pv-inner.pv-swap { animation: none; }
}
.panel.tail .tail-list { margin: 12px 0 0; padding-left: 1.6em; color: var(--muted); font-size: 14.5px; line-height: 1.7; }
.panel.tail .tail-list li { margin-bottom: 4px; }
.panel.tail mark { background: #fff2a8; border-radius: 3px; padding: 0 3px; }


/* ==========================================================================
   มือถือ (portrait) — หลังบ้านระบบร่างคำฟ้อง
   หลักคิด: แถบบนบรรทัดเดียวที่ติดบนจอ · เมนูขั้นตอนเป็นแถบเลื่อนแนวนอนที่ติดใต้แถบบน ·
   ปุ่ม ย้อนกลับ/ถัดไป ติดล่างจอ (กดด้วยนิ้วโป้ง) · ตัวอย่างเอกสารเป็นแผ่นเต็มจอ · ป๊อปอัปเป็น bottom sheet
   ช่องกรอก 16px (กัน iOS ซูมเอง) · พื้นที่กด ≥ 44px · เว้น safe-area รอยบาก/แถบล่าง
   (ต่อท้ายไฟล์ · ไม่แตะจอ ≥ 1024px)
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }
a, button, select, input, textarea, label, summary { touch-action: manipulation; }
.pv-close { display: none; }
/* แก้บั๊กเดิม: ป๊อปอัปโทน info ได้คลาส .info ซึ่งไปชนกับกฎไอคอน (i) วงกลม 18px → การ์ดยุบเหลือจุดเล็ก ๆ */



@media (max-width: 760px) {
  :root { --gutter: 14px; }
  body { overflow-wrap: break-word; }


  /* ---------- เมนูขั้นตอน: ลิ้นชักแนวตั้งเลื่อนเข้าจากซ้าย (กฎอยู่ท้าย admin-work.css) ---------- */

  /* ---------- เนื้อหา ---------- */
  .work { min-height: calc(100vh - var(--tb-h)); min-height: calc(100dvh - var(--tb-h)); }
  .main { padding: 16px var(--gutter) calc(24px + env(safe-area-inset-bottom, 0px)); }
  .main:has(> .wiz-nav) { padding-bottom: 0; }
  /* ช่องที่ถูกโฟกัส/เลื่อนไปหา ต้องไม่ไปซ่อนใต้แถบบน+แถบเมนูที่ติดอยู่ หรือแถบปุ่มล่าง */
  .main :is(input, select, textarea, summary, .panel, details) { scroll-margin-top: calc(var(--tb-h) + 16px); scroll-margin-bottom: 140px; }
  .main h2 { font-size: 22px; }
  .main .sub { font-size: 15px; margin-bottom: 18px; }
  .panel { border-radius: 14px; margin-bottom: 12px; }
  .grid, .agrp { gap: 16px 12px; }
  .grid > .f.s8 + .f.s4, .grid > .f.s7 + .f.s4 { grid-column: span 12; }
  .grp-t, .d-sub, .iss-h { font-size: 13.5px; }
  .item-toolbar select, .lay-form select, .ft-grp select { min-height: 44px; font-size: 16px; }
  .lay-in input[type=number] { width: 84px; min-height: 44px; font-size: 16px; }
  details.more > summary, details.iss-fold > summary, details.prec > summary { min-height: 44px; }
  .more-t { font-size: 15px; }
  details.item > summary { padding: 8px 12px; min-height: 60px; }
  details.item > .d-body { padding: 16px 14px; }
  .sum-name { font-size: 16px; }
  .sum-meta { font-size: 14px; }
  .ctag { font-size: 13px; }
  .nav-head small { font-size: 13px; }
  .rows > li { min-height: 60px; }
  .sum-badges { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  input[type=range] { height: 44px; }
  .rows .r-note { font-size: 14px; }
  .doc-pick { grid-template-columns: 1fr; }
  .fact .ctl { flex-direction: row; }

  /* ---------- ปุ่ม ย้อนกลับ / ถัดไป: ติดล่างจอ ---------- */
  .wiz-nav { position: sticky; bottom: 0; z-index: 12; margin: 24px calc(var(--gutter) * -1) 0; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #d9d9df;
    background: rgba(245, 245, 247, .94); -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%); }
  .wiz-btns { flex-wrap: nowrap; gap: 10px; }
  .wiz-btns > span:empty { display: none; }
  .wiz-btns .btn { flex: 1 1 0; min-width: 0; min-height: 50px; padding: 4px 10px; line-height: 1.25; text-align: center; font-size: 15px; }
  .wiz-miss { max-height: 92px; overflow-y: auto; overscroll-behavior: contain; margin: 0 0 10px; padding: 8px 12px; font-size: 13.5px; line-height: 1.45; border-radius: 12px; }
  .wiz-miss ul { margin: 2px 0 0; padding-left: 1.2em; }

  /* ---------- หน้าแรก (คดีของฉัน) ---------- */
  /* ปุ่มสร้างคดี: อาญา/แพ่งใหญ่ 2 ช่อง · สมุดรายชื่อ/กล่องข้อความ/นำเข้า เป็นแถวเล็ก 3 ช่อง */

  /* ---------- ตัวอย่างเอกสาร: แผ่นเต็มจอ ---------- */
  .work.showpv .preview { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; z-index: 60; box-shadow: none; }
  .work.showpv .pv-bar { padding-top: calc(10px + env(safe-area-inset-top, 0px)) !important; padding-left: max(12px, env(safe-area-inset-left)) !important; padding-right: max(12px, env(safe-area-inset-right)) !important; background: #ebebef; box-shadow: 0 1px 0 rgba(0, 0, 0, .1); }
  .pv-scroll { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  body:has(.work.showpv) { overflow: hidden; }

  /* ---------- ป๊อปอัป: bottom sheet ---------- */


  /* ---------- เข้าสู่ระบบ ---------- */

  /* ---------- สมุดรายชื่อ / กล่องข้อความ ---------- */
  .bookpage .f.s2, .bookpage .f.s3, .bookpage .f.s4 { grid-column: span 6; } /* หน้านี้ไม่อยู่ใน container ของ .main จึงต้องจัดคอลัมน์เอง */

  /* ---------- หน้า “ตั้งค่า & แม่แบบ” ---------- */
  .lay-line { grid-template-columns: minmax(0, 1fr) auto; }
  .lay-name { grid-column: 1 / -1; font-size: 15px; }
  .lay-bar { padding: 10px 12px; }
  .fit-foot { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tbl-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  table.simple { font-size: 15px; }
}
@keyframes modal-sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* จอสัมผัสกว้างกว่า 760px (แท็บเล็ต / มือถือหมุนข้าง): ส่วนประกอบเฉพาะหน้าทำงานให้กดง่ายขึ้น (ปุ่ม/ช่องกรอกกลางดู admin-base.css) */
@media (pointer: coarse) and (max-width: 1023px) and (min-width: 761px) {
  .item-toolbar select, .lay-form select, .ft-grp select, .pv-select select { min-height: 44px; font-size: 16px; }
  .steps .nav-item { min-height: 44px; }
  details.more > summary, details.iss-fold > summary, details.prec > summary { min-height: 44px; }
}
/* ---------- แชร์คดี & PDF ชุดเอกสาร (js/share.js) ---------- */
.share-panel .share-btns { margin: 12px 0 0; }
.share-panel .share-prog { min-height: 20px; margin: 8px 0 0; }
.share-panel .share-sub { margin: 24px 0 8px; }
.share-link, .share-invite { display: flex; gap: 8px; align-items: center; }
.share-link input, .share-invite input { flex: 1; min-width: 0; }
.share-link input { font-size: 14px; }
.share-err { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--err-bg); color: var(--err); margin-bottom: 12px; font-size: 14px; }
.share-err .ico { flex: none; margin-top: 2px; }
.share-panel .hint { margin: 8px 0 0; }
@media (max-width: 760px) {
  .share-link, .share-invite { flex-wrap: wrap; }
  .share-link input, .share-invite input { flex-basis: 100%; }
}

/* สลับฝั่งโจทก์/จำเลย ในเมนูคดี */
.side-switch { display: flex; gap: 2px; width: 100%; box-sizing: border-box; margin: 6px 0 8px; padding: 3px; background: var(--surface-3); border-radius: 12px; }
.side-switch button { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: #4b5563; font: inherit; font-size: 14px; font-weight: 500; line-height: 1.25; cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s; }
@media (hover: hover) { .side-switch button:hover { color: var(--ink); } }
.side-switch button.on, .side-switch button[aria-pressed=true] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(16, 24, 40, .14); }
.side-switch button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.side-note { margin: -2px 0 8px; padding: 0 12px; color: var(--muted, #6b7280); font-size: 12.5px; line-height: 1.4; }
@media (max-width: 760px) { .side-switch button { min-height: 44px; } }
