@font-face { font-family: "THSarabun"; src: url("/try/kheesuak/static/fonts/THSarabun.ttf"); }
@font-face { font-family: "THSarabun"; src: url("/try/kheesuak/static/fonts/THSarabun%20Bold.ttf"); font-weight: 700; }

:root {
  --bg: #f6f3ee; --surface: #ffffff; --ink: #1d1b19; --muted: #6d665e; --line: #e4ddd3;
  --accent: #e0661b; --accent-ink: #ffffff; --accent-soft: #fdeee3;
  --ok: #2f7d4f; --ok-soft: #e4f3ea; --warn: #b7791f; --warn-soft: #fbf1dc;
  --bad: #b83a3a; --bad-soft: #f9e4e4; --info: #3a5fb8; --info-soft: #e5ebf9;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --surface: #211e1b; --ink: #f1ece6; --muted: #a59d93; --line: #35302b;
    --accent: #f07a2e; --accent-soft: #3a2618;
    --ok: #6cc690; --ok-soft: #1d3326; --warn: #e2ad55; --warn-soft: #3a2f19;
    --bad: #ec7d7d; --bad-soft: #3d2121; --info: #8aa6ef; --info-soft: #1f2843;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 "Leelawadee UI", "Leelawadee", Tahoma, sans-serif;
}
h1, h2, h3 { font-family: "THSarabun", "Leelawadee UI", sans-serif; font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 28px; }
h3 { font-size: 23px; }
small, .muted { color: var(--muted); }
a { color: var(--info); }
.hidden { display: none !important; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.logo { font-family: "THSarabun", sans-serif; font-weight: 700; font-size: 38px; color: var(--accent); line-height: 1; }
.logo .az { font-family: "Leelawadee UI", Tahoma, sans-serif; font-size: 22px; letter-spacing: .5px; vertical-align: 4px; }
.tag { margin-left: 12px; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 80px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
input[type=text], input:not([type]), input[type=password], input[type=number], input[type=date], select {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink);
}
textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); resize: vertical;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.links { margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.card h3 { margin-top: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 18px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { height: 110px; border-radius: 8px; border: 1px solid var(--line); }
a.btn { display: inline-block; text-decoration: none; border-radius: 10px; padding: 9px 18px; border: 1px solid var(--line); color: var(--ink); }
a.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
code { font-size: 12.5px; word-break: break-all; }
p.consent { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 15px; }
label.links small.muted { font-weight: 400; }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.lvl {
  position: relative; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; font-weight: 400; gap: 2px;
}
.lvl input { position: absolute; opacity: 0; }
.lvl b { font-size: 16px; }
.lvl span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.lvl:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.lvl:has(input:focus-visible) { outline: 2px solid var(--accent); }

.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 18px; }
button { font: inherit; border-radius: 10px; padding: 9px 18px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; }
button.soon { opacity: .55; cursor: not-allowed; }

.progress-head { display: flex; align-items: center; gap: 12px; }
.progress-head h2 { margin: 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.log { font-size: 14px; color: var(--muted); max-height: 260px; overflow: auto; padding-left: 22px; margin: 10px 0 0; }

/* report */
.rep-head { border-left: 5px solid var(--accent); }
.rep-head .headline { font-size: 18px; margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; line-height: 1.5; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
  white-space: normal; overflow-wrap: anywhere; max-width: 100%; box-sizing: border-box; }
/* long status text (lead 26, 3 Nov): wraps inside the card; past 3 lines it folds behind "ดูเพิ่ม" */
.chip:has(+ .more) { border-radius: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
button.more { background: none; border: 0; padding: 0 4px; color: var(--accent); font-size: 12.5px; cursor: pointer; text-decoration: underline; }
dialog.dup { max-width: 560px; width: calc(100% - 32px); }
.dup-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.dup-item .row, dialog.dup > .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.sec-num { color: var(--accent); margin-right: 6px; }
.story p { margin: 0 0 .8em; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.char { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.char h3 { margin-bottom: 2px; }
.char ul { margin: 6px 0 0; padding-left: 20px; font-size: 15px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 16px; }
.timeline li::before { content: ""; position: absolute; left: -30px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); }
.tl-date { font-weight: 700; }
.tl-place { color: var(--muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.tbl-wrap { overflow-x: auto; }
.prob { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.opinion { background: var(--accent-soft); border: 1.5px solid var(--accent); }
.opinion p { margin: 0 0 .7em; }
.evid { display: grid; gap: 10px; }
.evid > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.evid b { display: block; }
.extra { border: 1.5px dashed var(--accent); }
.sources { font-size: 14px; padding-left: 26px; }
.sources li { margin-bottom: 4px; word-break: break-word; }
.src { font-size: 12px; vertical-align: super; color: var(--info); text-decoration: none; margin-left: 1px; }
.disclaimer { font-size: 13.5px; color: var(--muted); }
.next { display: flex; gap: 10px; flex-wrap: wrap; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg { padding: 22px 24px; }
.history { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto; }
.history li { padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.history li:hover { background: var(--bg); }

@media (max-width: 760px) {
  .grid3, .grid2, .levels { grid-template-columns: 1fr; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top-actions { gap: 6px; justify-content: flex-start; }
  .top-actions .btn, .top-actions button { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .tag { display: none; }
  .card { padding: 18px 16px; }
}
@media print {
  .top, #formCard, .next, dialog { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid-page; }
}

/* คลังตัวบท */
.law-refs { margin-top: 6px; }
button.chip.law-chip { cursor: pointer; font: inherit; font-size: 12.5px; }
.law-sec { border-top: 1px solid var(--line); padding: 12px 0; }
.law-head { margin-bottom: 4px; }
.law-text p { margin: 0 0 .4em; }
.law-notes { font-size: 13px; color: var(--muted); margin-top: 4px; }
#dlgLaw .dlg { max-width: 720px; }/* คลังแหล่งข่าว: a source that is no longer public */
.gone { margin: 6px 0 4px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); border-left: 3px solid var(--warn); font-size: 14px; overflow-wrap: anywhere; }
.gone b { color: var(--warn); }
.gone-note { border-left: 4px solid var(--warn); background: var(--warn-soft); }

/* ทีม F: กล่อง เสือกรับคดี */
.take-case .redbox, #detail .redbox { border: 2px solid #c62828; background: #fdecea; color: #8e0000; padding: 10px 12px; border-radius: 8px; font-weight: 600; margin: 8px 0; }
.take-case input:not([type]) { display: block; margin: 8px 0; padding: 6px 8px; width: min(360px, 100%); }
.take-case button:disabled { opacity: .5; cursor: not-allowed; }

/* ทีม F: รายการงานกดเปิดได้ */
ul.history li.clickable { cursor: pointer; }
ul.history li.clickable:hover { background: #fff3e0; }

/* ทีม F: โลโก้กดกลับหน้าแรก */
a.brand { color: inherit; text-decoration: none; cursor: pointer; }

/* ทีม F: ช่องที่ยังไม่กรอก — เห็นชัด */
.invalid { border: 2px solid #c62828 !important; background: #fdecea !important; }
.form-error { color: #c62828; font-weight: 700; font-size: 15px; }

/* ทีม F: ขั้นตอนนำทาง /trace */
.step { display: inline-block; width: 1.6em; height: 1.6em; line-height: 1.6em; text-align: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; }
.step-head { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
button.big, .btn.big { font-size: 17px; padding: 12px 20px; }

