:root {
  --bg: #FBF7EE;
  --card: #FFFFFF;
  --ink: #2B2118;
  --ink-soft: #6B5F52;
  --gold: #F9A825;
  --gold-dark: #C9800F;
  --line: #EAE1D2;
  --danger: #D64545;
  --ok: #2E7D4F;
  --radius: 20px;
  --icon-a: #FFE3D1; /* peach */
  --icon-b: #DCEFE3; /* mint */
  --icon-c: #E4E1FA; /* lavender */
  --icon-d: #DDEEF9; /* sky */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Prompt', 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
}

.phone-shell {
  width: 100%;
  max-width: 440px;
}

.brandbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.brandbar img { height: 34px; }
.brandbar .name { font-size: 13px; color: var(--ink-soft); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(43,33,24,.06);
  border: 1px solid var(--line);
}

/* ---------- progress ---------- */
.progress-wrap { margin-bottom: 22px; }
.progress-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: .04em; }
.progress-track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-dark)); border-radius: 99px; transition: width .35s ease; }

/* ---------- landing ---------- */
.mascot { text-align: center; margin-bottom: 8px; }
.mascot img { width: 140px; }
.event-title { font-size: 20px; font-weight: 700; line-height: 1.5; text-align: center; margin: 6px 0 14px; }
.event-meta { font-size: 14px; color: var(--ink-soft); text-align: center; line-height: 1.8; margin-bottom: 22px; }
.event-meta b { color: var(--ink); }

/* ---------- headings ---------- */
h2.step-title { font-size: 19px; margin: 0 0 4px; }
p.step-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }

/* ---------- school list ---------- */
.school-list { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; }
.school-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.school-item:hover { border-color: var(--gold); }
.school-item.selected { border-color: var(--gold); background: #FFF6E5; }
.school-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.school-name { font-size: 14.5px; flex: 1; }
.school-status { font-size: 11.5px; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.status-empty { background: #F1EEE6; color: var(--ink-soft); }
.status-done { background: #E4F3EA; color: var(--ok); }

/* ---------- form fields with icons ---------- */
.field-group { margin-bottom: 16px; }
.field-group.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px;
  background: #FEFDFB;
}
.field:focus-within { border-color: var(--gold); }
.field.error { border-color: var(--danger); }
.icon-badge {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.field input, .field select {
  border: none; outline: none; background: transparent; font-size: 14.5px;
  width: 100%; font-family: inherit; color: var(--ink);
}
.field-error-text { color: var(--danger); font-size: 12px; margin-top: 4px; margin-left: 4px; }
.field-hint { font-size: 11.5px; color: var(--ink-soft); margin: 4px 0 0 4px; }
/* มือถือ: ช่องกรอกต้อง 16px ขึ้นไป ไม่งั้น iPhone ซูมหน้าจอเองทุกครั้งที่แตะช่อง
   (เดิมแก้ด้วยการปิดซูมทั้งหน้า ซึ่งทำให้ครูที่สายตาไม่ดีขยายตัวอักษรไม่ได้) */
@media (max-width: 600px) {
  .field input, .field select { font-size: 16px; }
}

.section-label {
  font-size: 13px; font-weight: 700; color: var(--ink);
  margin: 22px 0 12px; padding-top: 14px; border-top: 1px dashed var(--line);
}

.backup-toggle {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; color: var(--ink-soft); margin-top: -4px; margin-bottom: 10px;
}
.switch { position: relative; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--line);
  border-radius: 99px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--gold); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ---------- review ---------- */
.review-block { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.review-block h4 { margin: 0 0 8px; font-size: 13.5px; color: var(--gold-dark); }
.review-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; }
.review-row span:first-child { color: var(--ink-soft); }

/* ---------- success ---------- */
.success-icon { text-align: center; font-size: 52px; margin-bottom: 6px; }
.success-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.success-sub { text-align: center; font-size: 13.5px; color: var(--ink-soft); line-height: 1.8; margin-bottom: 18px; }
.link-box {
  background: #FFF6E5; border: 1px dashed var(--gold); border-radius: 12px;
  padding: 12px 14px; font-size: 12.5px; word-break: break-all; color: var(--gold-dark);
  display: block; text-decoration: none;
}
.link-box:hover { text-decoration: underline; }
.qr-box { display: flex; justify-content: center; margin: 16px 0 4px; }
.qr-box img, .qr-box canvas { border-radius: 12px; border: 1px solid var(--line); padding: 10px; background: #fff; }

/* ---------- buttons ---------- */
.btn-row { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  flex: 1; padding: 14px; border-radius: 14px; border: none; font-size: 15px;
  font-weight: 700; cursor: pointer; font-family: inherit; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: white; }
.btn-primary:disabled { background: #C9C1B4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); flex: 0 0 90px; }

.alert-banner {
  background: #FDECEC; color: var(--danger); border-radius: 12px; padding: 12px 14px;
  font-size: 13px; margin-bottom: 16px; display: none;
}
.alert-banner.show { display: block; }

.footer-power { text-align: center; font-size: 11.5px; color: var(--ink-soft); margin-top: 18px; }