@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/noto-sans-thai-looped-thai-400.woff2) format('woff2'); unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/noto-sans-thai-looped-thai-600.woff2) format('woff2'); unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/noto-sans-thai-looped-thai-700.woff2) format('woff2'); unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/noto-sans-thai-looped-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/noto-sans-thai-looped-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Noto Sans Thai Looped'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/noto-sans-thai-looped-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --primary: #0B6B3A;
  --primary-dark: var(--primary);
  --primary-ink: var(--primary);
  --primary-soft: #DCEFE3;
  --bg: #F2F3F1;
  --card: #FFFFFF;
  --text: #17201B;
  --text-2: #3F4A44;
  --muted: #56615B;
  --line: #E1E5E2;
  --disabled: #C9D1CC;
  --ok: #08522C;
  --ok-bg: #E3F3E9;
  --warn: #B54708;
  --warn-bg: #FFF4E5;
  --err: #8F1D14;
  --err-bg: #FDECEA;
  --info: #1D5FD1;
  --grey-badge: #56615B;
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --primary-dark: color-mix(in srgb, var(--primary) 78%, black);
    --primary-ink: color-mix(in srgb, var(--primary) 70%, black);
    --primary-soft: color-mix(in srgb, var(--primary) 14%, white);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans Thai Looped', 'Leelawadee UI', 'Thonburi', 'Sarabun', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
body.dark { background: #101412; color: #fff; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.3; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
p { margin: 0; }
b { font-weight: 600; }
a { color: var(--primary-ink); }

.small { font-size: 14px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.accent { color: var(--primary-ink); }
.lead { font-size: 18px; font-weight: 600; }
.body-text { font-size: 16px; line-height: 1.6; color: var(--text-2); }
.center { text-align: center; align-items: center; }
.center-text { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex-grow: 1; }
.grow-center { flex-grow: 1; justify-content: center; }
.section-title { margin-top: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }

/* Screens */
.screen { display: flex; flex-direction: column; gap: 14px; flex-grow: 1; }
.screen[hidden] { display: none; }
.center-all { align-items: center; justify-content: center; text-align: center; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(20, 30, 25, 0.08);
}
.card.row { flex-direction: row; align-items: center; gap: 14px; }

/* Brand header */
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; overflow: hidden; flex-shrink: 0;
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-title { font-size: 17px; font-weight: 600; }

/* Buttons */
.actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(242, 243, 241, 0), var(--bg) 18px);
}
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 48px; border: 0; border-radius: 14px; padding: 0 16px;
  font-family: inherit; font-size: 18px; font-weight: 600; cursor: pointer;
}
.btn-primary { height: 56px; background: var(--primary); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--disabled); color: var(--muted); cursor: not-allowed; }
.btn-primary.btn-warn { background: var(--warn); }
.btn-outline { border: 2px solid var(--primary); background: #fff; color: var(--primary-ink); font-size: 16px; }
.btn-text { background: transparent; color: var(--primary-ink); font-size: 16px; font-weight: 500; }
.btn:disabled { cursor: not-allowed; }
.link-center { text-align: center; font-size: 16px; font-weight: 500; padding: 12px; min-height: 48px; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }

/* Spinner and check pop */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 22px; height: 22px; border-width: 3px; border-color: rgba(255, 255, 255, 0.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.check-badge {
  width: 72px; height: 72px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 6px;
}
.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .pop { animation: none; }
}

/* Error */
.icon-circle {
  width: 64px; height: 64px; border-radius: 50%; background: var(--warn-bg); color: var(--warn);
  display: flex; align-items: center; justify-content: center;
}

/* Messages and badges */
.msg { border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.5; }
.msg-error { background: var(--err-bg); color: var(--err); }
.msg-warn { background: var(--warn-bg); color: var(--warn); }
.badge {
  display: inline-block; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 26px;
  background: var(--ok-bg); color: var(--ok);
}
.badge-warn { background: var(--warn); color: #fff; }
.badge-grey { background: var(--grey-badge); color: #fff; }
.badge-info { background: transparent; color: var(--info); padding: 0; }

/* Register */
.field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; cursor: text; }
.otp-box {
  height: 56px; border-radius: 12px; border: 2px solid var(--disabled); background: #F7F8F7;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 600;
}
.otp-box.filled { border-color: var(--primary); background: #fff; }
.otp-box.active { border-color: var(--info); background: #fff; }
.sr-input {
  position: absolute; opacity: 0; width: 1px; height: 1px; left: 0; font-size: 16px;
}
.big-name { font-size: 28px; font-weight: 700; line-height: 1.3; }
.consent-box {
  font-size: 15px; line-height: 1.7; color: var(--text-2); flex-grow: 1; min-height: 120px; max-height: 40vh;
  overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.check-row { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.5; min-height: 48px; }
.check-row input { width: 24px; height: 24px; margin: 0; accent-color: var(--primary); flex-shrink: 0; }
.success-title { font-size: 20px; font-weight: 700; color: var(--ok); }

/* Stepper */
.stepper { display: flex; justify-content: center; gap: 8px; font-size: 14px; }
.pill { padding: 4px 12px; border-radius: 999px; background: var(--line); color: var(--muted); }
.pill.done { background: var(--primary); color: #fff; font-weight: 600; }
.pill.current { background: var(--text); color: #fff; font-weight: 600; }
body.dark .pill { background: #2A302D; color: #B8C1BC; }
body.dark .pill.done { background: var(--primary); color: #fff; }
body.dark .pill.current { background: #fff; color: #101412; }

/* Profile mini card and bars */
.profile-mini { gap: 10px; padding: 14px 16px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-big { height: 8px; border-radius: 4px; }
.bar-fill { height: 100%; width: 0; background: var(--primary); border-radius: inherit; }

/* Location ring */
.ring { position: relative; width: 240px; height: 240px; flex-shrink: 0; }
.ring-zone {
  position: absolute; left: 50px; top: 50px; width: 140px; height: 140px; border-radius: 50%;
  border: 3px dashed var(--primary); background: var(--primary-soft);
}
.ring-center { position: absolute; left: 114px; top: 114px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.ring-label { position: absolute; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ring-branch { left: 108px; top: 130px; color: var(--primary-ink); }
.ring-me {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; background: var(--info);
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(29, 95, 209, 0.18); transform: translate(-50%, -50%);
}
.ring-mename { color: var(--info); transform: translate(-50%, 0); }
.ring.out .ring-me { background: #B42318; box-shadow: 0 0 0 6px rgba(180, 35, 24, 0.18); }
.ring.out .ring-mename { color: #B42318; }
.status-box { width: 100%; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--line); color: var(--text); }
.status-box b { font-size: 17px; font-weight: 700; }
.status-box span { font-size: 15px; line-height: 1.5; }
.status-box.ok { background: var(--ok-bg); color: var(--ok); }
.status-box.out { background: var(--err-bg); color: var(--err); }
.status-box.warn { background: var(--warn-bg); color: var(--warn); }
.help-box { width: 100%; text-align: left; font-size: 15px; line-height: 1.6; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

/* Camera */
.camera-frame {
  position: relative; flex-grow: 1; min-height: 320px; border-radius: 20px; background: #2A302D; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.camera-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.oval { width: 210px; height: 280px; max-width: 70%; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.85); position: relative; }
.camera-hint { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; font-size: 16px; font-weight: 500; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.camera-fallback {
  position: absolute; inset: 0; background: #2A302D; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 24px; text-align: center; line-height: 1.6;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.visually-hidden:focus-visible + label { outline: 3px solid var(--info, #1D5FD1); outline-offset: 2px; }
.shutter-row { display: flex; justify-content: center; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: var(--primary); padding: 0; cursor: pointer; }
.shutter:active { transform: scale(0.94); }
.camera-note { text-align: center; color: #B8C1BC; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.screen#s-camera { gap: 16px; }

/* Preview */
.preview-frame { flex-grow: 1; min-height: 320px; border-radius: 20px; background: var(--disabled); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.preview-frame img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Success slip */
.big-time { font-size: 44px; font-weight: 700; line-height: 1.1; }
.thumb { width: 72px; height: 96px; border-radius: 10px; object-fit: cover; background: var(--disabled); flex-shrink: 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }

/* History */
.day-card { gap: 6px; padding: 14px 16px; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-head b { font-size: 16px; }
.day-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.day-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); font-size: 15px; color: var(--text-2); gap: 4px; }
.day-note { font-size: 14px; color: var(--muted); }
.dashed { border: 2px dashed var(--disabled); border-radius: 16px; padding: 14px 16px; font-size: 15px; color: var(--muted); text-align: center; }

/* Help */
.num {
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0;
}
