/* Nano Daily Check
   สีมาจากเว็บ nano-seimitsu.com: กรมท่า #001652 และฟ้า #2D96DB
   หัวข้อใช้ Prompt (ตัวเดียวกับเว็บบริษัท) เนื้อความใช้ IBM Plex Sans Thai Looped ที่มีหัวตัวอักษร อ่านง่ายแบบแบบฟอร์มกระดาษ
   ตัวเลขมิเตอร์ใช้ IBM Plex Mono */

@font-face { font-family: Prompt; font-weight: 600; font-display: swap; src: url(fonts/prompt-thai-600-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: Prompt; font-weight: 600; font-display: swap; src: url(fonts/prompt-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-2199, U+2212; }
@font-face { font-family: Prompt; font-weight: 700; font-display: swap; src: url(fonts/prompt-thai-700-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: Prompt; font-weight: 700; font-display: swap; src: url(fonts/prompt-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-2199, U+2212; }
@font-face { font-family: 'Plex Looped'; font-weight: 400; font-display: swap; src: url(fonts/plex-looped-thai-400.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Plex Looped'; font-weight: 400; font-display: swap; src: url(fonts/plex-looped-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-2199, U+2212; }
@font-face { font-family: 'Plex Looped'; font-weight: 600; font-display: swap; src: url(fonts/plex-looped-thai-600.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Plex Looped'; font-weight: 600; font-display: swap; src: url(fonts/plex-looped-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-2199, U+2212; }
@font-face { font-family: 'Plex Mono'; font-weight: 600; font-display: swap; src: url(fonts/plex-mono-600.woff2) format('woff2'); }

:root {
  --navy: #001652;
  --blue: #2d96db;
  --blue-deep: #1670b5;
  --paper: #eaf1f7;
  --card: #ffffff;
  --ink: #0a1633;
  --muted: #51607a;
  --line: #c9d6e3;
  --ok: #0b7a43;
  --ok-bg: #dcf2e5;
  --ng: #c92a1b;
  --ng-bg: #fbe3df;
  --amber: #f2b400;
  --head: Prompt, 'Plex Looped', system-ui, sans-serif;
  --text: 'Plex Looped', system-ui, 'Noto Sans Thai', sans-serif;
  --mono: 'Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 17px/1.55 var(--text); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
p, h1, h2, h3 { margin: 0; }
svg { display: block; flex: none; }

#view { display: flex; flex-direction: column; min-height: 100%; max-width: 640px; margin: 0 auto; background: var(--paper); }
main { flex: 1; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- แถบบน ---------- */
.top { background: var(--navy); color: #fff; border-bottom: 4px solid var(--blue); padding: 10px 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 3; min-height: 60px; }
.top .mark { width: 30px; height: 30px; }
.top h1 { font: 700 19px/1.2 var(--head); letter-spacing: .01em; flex: 1; }
.top .where { flex: 1; min-width: 0; }
.top .where b { display: block; font: 600 16px/1.25 var(--head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .where small { display: block; font-size: 13px; opacity: .75; font-family: var(--mono); }
.top .step { font: 600 15px var(--head); white-space: nowrap; }
.top .step b { font-size: 24px; }
.ghost { background: none; border: 0; color: inherit; min-height: 44px; padding: 6px 4px; display: inline-flex; align-items: center; gap: 6px; font: 600 15px var(--head); }
.who { text-align: right; line-height: 1.15; flex-direction: column; align-items: flex-end; gap: 0; }
.who small { font: 400 12px var(--text); opacity: .75; }

/* ---------- ปุ่ม ---------- */
.btn { border: 2px solid var(--line); background: var(--card); border-radius: 10px; min-height: 58px; padding: 12px 18px; font: 600 17px var(--head); display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn:disabled { opacity: .35; }
.btn.primary { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.btn.scan { width: 100%; min-height: 84px; font-size: 21px; background: var(--navy); border-color: var(--navy); color: #fff; justify-content: flex-start; padding-left: 20px; gap: 16px; position: relative; overflow: hidden; }
.btn.scan::after { content: ''; position: absolute; right: -30px; top: -30px; width: 150px; height: 150px; border: 22px solid var(--blue); opacity: .35; border-radius: 28px; transform: rotate(12deg); }
.btn.scan small { display: block; font: 400 14px var(--text); opacity: .8; }
.bar { display: flex; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); position: sticky; bottom: 0; z-index: 2; }
.bar .btn { flex: 1; }
.bar .btn.primary { flex: 2; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.hello { background: var(--navy); color: #fff; padding: 44px 20px 36px; border-bottom: 6px solid var(--blue); }
.hello .mark { width: 56px; height: 56px; margin-bottom: 18px; }
.hello h1 { font: 700 34px/1.1 var(--head); }
.hello p { opacity: .8; margin-top: 8px; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person { border: 2px solid var(--line); background: var(--card); border-radius: 10px; padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; font: 600 19px var(--head); min-height: 132px; }
.person i { width: 56px; height: 56px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font: 700 24px var(--head); font-style: normal; }

/* ---------- หน้าหลัก ---------- */
.today { background: var(--card); border-radius: 10px; padding: 16px; border: 1px solid var(--line); }
.today .date { color: var(--muted); font-size: 15px; }
.today h2 { font: 700 24px/1.25 var(--head); margin: 2px 0 12px; }
.segs { display: flex; gap: 4px; }
.segs i { flex: 1; height: 10px; border-radius: 3px; background: var(--line); }
.segs i.ok { background: var(--ok); }
.segs i.ng { background: var(--ng); }
.segs i.cur { background: var(--blue); }
.segs.thin i { height: 6px; }
.label { font: 600 15px var(--head); color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 10px; }
.point { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--line); border-radius: 10px; overflow: hidden; }
.point.done { border-left-color: var(--ok); }
.point .go { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 14px 8px 14px 12px; display: flex; gap: 12px; align-items: center; min-height: 84px; }
.point .ic { width: 44px; height: 44px; border-radius: 8px; background: var(--paper); color: var(--navy); display: grid; place-items: center; }
.point .ic svg { width: 26px; height: 26px; }
.point b { display: block; font: 600 17px/1.3 var(--head); }
.point code { font: 600 13px var(--mono); color: var(--muted); }
.point .state { display: block; font-size: 14px; color: var(--muted); }
.point.done .state { color: var(--ok); font-weight: 600; }
.point .hist { border: 0; border-left: 1px solid var(--line); background: none; width: 60px; color: var(--blue-deep); display: grid; place-items: center; }
.point .hist svg { width: 24px; height: 24px; }

.switch { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.switch input { appearance: none; width: 52px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; margin: 0; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--blue-deep); }
.switch input:checked::after { transform: translateX(22px); }
.switch b { display: block; font: 600 16px var(--head); }
.switch small, .fine { color: var(--muted); font-size: 14px; }

/* ---------- หน้าตรวจ ---------- */
.q h2 { font: 700 26px/1.25 var(--head); }
.q .crit { margin-top: 6px; font-size: 18px; }
.chip { display: inline-block; font: 600 13px var(--head); padding: 2px 10px; border-radius: 4px; background: var(--navy); color: #fff; vertical-align: middle; margin-left: 6px; }
figure.ref { margin: 0; position: relative; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
figure.ref img { display: block; width: 100%; max-height: 230px; object-fit: contain; }
figure.ref figcaption { position: absolute; left: 0; top: 0; background: var(--navy); color: #fff; font: 600 13px var(--head); padding: 3px 10px; border-bottom-right-radius: 8px; }

.okng { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.okng button { min-height: 104px; border-radius: 12px; border: 3px solid; background: var(--card); font: 700 32px var(--head); display: flex; align-items: center; justify-content: center; gap: 10px; }
.okng svg { width: 34px; height: 34px; }
.okng .ok { color: var(--ok); border-color: var(--ok); }
.okng .ng { color: var(--ng); border-color: var(--ng); }
.okng .ok.on { background: var(--ok); color: #fff; }
.okng .ng.on { background: var(--ng); color: #fff; }

.shot { width: 100%; min-height: 76px; border: 2px dashed var(--blue-deep); color: var(--blue-deep); background: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 12px; font: 600 17px var(--head); padding: 8px 14px; }
.shot svg { width: 28px; height: 28px; }
.shot.need { border-color: var(--ng); color: var(--ng); }
.shot.has { border-style: solid; border-color: var(--line); color: var(--ink); justify-content: flex-start; }
.shot img { height: 76px; width: 104px; object-fit: cover; border-radius: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 600 15px var(--head); color: var(--muted); }
.field input, .field textarea { border: 2px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--card); font-size: 19px; width: 100%; }
.field input:focus, .field textarea:focus { border-color: var(--blue-deep); outline: none; }
.field.num input { font: 600 30px var(--mono); text-align: center; }

.verdict { padding: 12px 16px; border-radius: 10px; background: #dfe7ef; font: 600 17px var(--head); display: flex; align-items: center; gap: 10px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.ng { background: var(--ng-bg); color: var(--ng); }
.verdict svg { width: 24px; height: 24px; }

/* ---------- สรุป: ตราประทับ ---------- */
.stampbox { display: flex; align-items: center; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.stamp { width: 104px; height: 104px; flex: none; border-radius: 50%; border: 5px double currentColor; display: grid; place-items: center; text-align: center; font: 700 22px/1.05 var(--head); transform: rotate(-9deg); color: var(--ok); }
.stamp.ng { color: var(--ng); }
.stamp small { display: block; font: 600 12px var(--head); }
.stampbox h2 { font: 700 21px/1.3 var(--head); }
@media (prefers-reduced-motion: no-preference) {
  .stamp { animation: press .32s cubic-bezier(.2, 1.4, .4, 1) both; }
  @keyframes press { from { transform: rotate(-9deg) scale(1.7); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 1; } }
}
.line { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-height: 56px; }
.line .n { font: 600 14px var(--mono); color: var(--muted); width: 22px; flex: none; }
.line .t { flex: 1; min-width: 0; }
.line .t small { display: block; color: var(--muted); font-size: 14px; }
.tag { font: 700 14px var(--head); padding: 3px 10px; border-radius: 4px; white-space: nowrap; background: #dfe7ef; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.ng { background: var(--ng-bg); color: var(--ng); }
.tag.wait { background: #fdf0c4; color: #7a5a00; }
.detail { flex-direction: column; align-items: stretch; }
.detail .row { display: flex; gap: 10px; align-items: center; }
.detail img { width: 132px; border-radius: 6px; }
img.full { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- มิเตอร์: หน้าปัดตัวเลขหมุน ---------- */
.drum { position: relative; background: #111418; border-radius: 12px; padding: 16px 14px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 3px solid #2a3038; box-shadow: inset 0 3px 10px #000; }
.drum.small { padding: 8px 10px; border-width: 2px; display: inline-flex; border-radius: 8px; }
.drum .cells { display: flex; gap: 6px; }
.drum .cell { width: 52px; height: 74px; border-radius: 6px; background: linear-gradient(#000 0, #23272e 50%, #000 100%); color: #fff; font: 600 46px/74px var(--mono); text-align: center; border: 1px solid #3a414b; }
.drum.small .cell { width: 24px; height: 34px; font-size: 20px; line-height: 34px; border-radius: 4px; }
.drum .cell.cur { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber); }
.drum .unit { color: #aab4c0; font: 600 16px var(--head); }
.drum input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
.prev { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }

.tip { display: flex; gap: 14px; align-items: center; background: #fdf6d9; border: 1px solid #ecd27a; border-radius: 10px; padding: 12px 14px; font-size: 15px; }
.tip b { font-family: var(--head); }
.roll { width: 40px; height: 56px; flex: none; border-radius: 5px; background: #111418; overflow: hidden; position: relative; border: 1px solid #3a414b; }
.roll span { position: absolute; left: 0; right: 0; text-align: center; color: #fff; font: 600 30px/40px var(--mono); }
.roll span:first-child { top: -14px; }
.roll span:last-child { top: 28px; }
.roll::after { content: ''; position: absolute; left: 0; right: 0; top: 27px; border-top: 1px solid #5b6470; }
.confirm { display: flex; flex-direction: column; gap: 10px; }

/* ---------- แถบเสียง ---------- */
#voicebar { position: sticky; top: 0; z-index: 4; background: var(--amber); color: #2b2000; font: 600 14px var(--head); padding: 5px 14px; display: flex; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; }
#voicebar svg { width: 18px; height: 18px; }
#voicebar.err { background: var(--ng); color: #fff; }
#voicebar[hidden], #camera[hidden], #toast[hidden] { display: none; }
#voicebar:not([hidden]) + #view .top { top: 31px; }

/* ---------- กล้อง ---------- */
#camera { position: fixed; inset: 0; background: #000; z-index: 10; }
#camera-video { width: 100%; height: 100%; object-fit: contain; }
#camera-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: .35; pointer-events: none; }
#camera-guide { position: absolute; left: 8%; right: 8%; top: 41%; height: 15%; border: 3px solid var(--amber); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); pointer-events: none; }
#camera-top, #camera-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff; font: 600 16px var(--head); }
#camera-top { top: 0; background: linear-gradient(#000c, #0000); }
#camera-bottom { bottom: 0; justify-content: space-between; padding-bottom: calc(22px + env(safe-area-inset-bottom)); background: linear-gradient(#0000, #000c); }
#camera button { background: #0009; color: #fff; border: 2px solid #fff9; border-radius: 10px; min-width: 104px; min-height: 52px; font: 600 15px var(--head); }
#camera button[hidden] { display: block; visibility: hidden; }
#camera button.on { background: var(--amber); color: #000; border-color: var(--amber); }
#camera #camera-shot { width: 80px; min-width: 80px; height: 80px; border-radius: 50%; background: #fff; border: 6px solid #fff8; }

#toast { position: fixed; left: 16px; right: 16px; bottom: 100px; margin: 0 auto; max-width: 480px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; text-align: center; z-index: 5; font: 600 16px var(--head); border-left: 6px solid var(--amber); }
