:root {
  --green: #58b947;
  --green-d: #3c8f2f;
  --green-l: #e3f6d9;
  --yellow: #ffc93c;
  --yellow-d: #e0a414;
  --orange: #ff8a3d;
  --cream: #fff8e7;
  --sky: #dff3f9;
  --ink: #2e3a28;
  --ink-2: #6b7562;
  --line: #e8e2cf;
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14px 14px, rgba(88,185,71,.10) 5px, transparent 6px) 0 0 / 52px 52px,
    linear-gradient(180deg, var(--cream) 0%, #fffdf6 50%, var(--sky) 100%) fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 20px calc(28px + env(safe-area-inset-bottom));
}

h1, h2, .brand, .btn, .stage-age, .bubble, .tab {
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
}

/* Header + progres ala story */
.top { margin-bottom: 16px; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .5px;
  color: var(--green-d);
  margin-bottom: 10px;
}
.brand-dino { width: 38px; height: 38px; flex: 0 0 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; flex: 1; min-width: 0; }
.brand-text b { font-weight: 700; }
.brand-text small { white-space: nowrap; font-family: "Nunito", system-ui, sans-serif; font-size: clamp(10.5px, 3.2vw, 12.5px); font-weight: 800; color: var(--ink-2); letter-spacing: 0; margin-top: 2px; }
.brand-logos { display: flex; gap: 6px; flex: none; }
.brand-logos img { width: 36px; height: 36px; display: block; }
.partners { display: flex; align-items: center; justify-content: center; gap: 14px; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 10px 14px; margin: 2px 0 10px; }
.partners img { height: 38px; width: auto; min-width: 0; flex: 0 1 auto; object-fit: contain; max-width: 45%; }
.partners i { width: 2px; align-self: stretch; background: var(--line); border-radius: 2px; }
.progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.progress i { height: 7px; border-radius: 99px; background: #ebe5d2; transition: background .3s; }
.progress i.on { background: var(--green); }

.screen { display: none; }
.screen.active { display: block; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

h1 { font-size: 27px; line-height: 1.18; margin: 4px 0 8px; font-weight: 700; }
.lead { margin: 0 0 18px; color: var(--ink-2); font-size: 16px; line-height: 1.45; }

/* Slide 1 – edukasi */
.hero {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 4px 0 14px;
}
.hero-dino { width: 120px; height: 120px; flex: 0 0 120px; }
.bubble {
  position: relative;
  background: #fff;
  border: 2.5px solid var(--green);
  border-radius: 20px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
  margin-bottom: 40px;
}
.bubble::before {
  content: "";
  position: absolute;
  left: -11px;
  bottom: 18px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-left: 2.5px solid var(--green);
  border-bottom: 2.5px solid var(--green);
  transform: rotate(45deg);
}
.edu { display: grid; gap: 12px; margin: 16px 0 20px; }
.edu-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.edu-ic {
  flex: 0 0 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.edu-ic svg { width: 40px; height: 40px; display: block; }
.c1 .edu-ic { background: var(--green-l); }
.c2 .edu-ic { background: #fff1c9; }
.c3 .edu-ic { background: #ffe3d0; }
.c4 .edu-ic { background: #dcefff; }
.edu-card h2 { font-size: 18px; margin: 2px 0 4px; font-weight: 600; }
.edu-card p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }

/* Slide 2 – foto */
.photo-pick { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 8px 0 20px; }
.photo-ring {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  padding: 9px;
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-d);
}
.photo-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 5px solid #fff;
  background: #fff center / cover no-repeat;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.photo-inner canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; display: none; }
.photo-inner.has-photo canvas { display: block; }
.cam { font-size: 64px; }
.photo-inner.has-photo .cam { display: none; }
.photo-adjust { width: 100%; text-align: center; }
.photo-adjust p { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--green-d); line-height: 1.4; }
.photo-adjust .zoom { margin-bottom: 0; }
.photo-adjust[hidden] { display: none; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 800; font-size: 15px; margin-bottom: 7px; }
.req { color: var(--orange); }
.field input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 15px 17px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
  min-height: 56px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(88,185,71,.18); }
.note { font-size: 14px; color: var(--ink-2); line-height: 1.45; margin: 4px 0 16px; }

/* Tombol ala chunky */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform .08s, box-shadow .08s, opacity .15s;
}
.btn.small { font-size: 16px; padding: 13px 10px; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-d); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-d); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--green-d); }
.btn.ghost { background: #fff; color: var(--green-d); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.wa { background: #25d366; color: #fff; box-shadow: 0 5px 0 #179a4a; }
.btn.wa:active { transform: translateY(4px); box-shadow: 0 1px 0 #179a4a; }
.btn.wa svg { width: 24px; height: 24px; }
.btn.sticky { position: sticky; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 5; }
#restart { margin-top: 4px; }

.back {
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-weight: 800;
  padding: 6px 0;
  margin-bottom: 2px;
  cursor: pointer;
}

/* Slide 3 – tahap imunisasi */
.stages { display: grid; gap: 10px; margin-bottom: 18px; }
.stage {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.stage { cursor: default; }
.stage.has-today { border-color: var(--orange); background: #fff8f1; box-shadow: 0 4px 0 var(--orange); }
.stage.full:not(.has-today) { background: #fbfdf8; }
.stage-age {
  flex: 0 0 62px;
  height: 62px;
  border-radius: 18px;
  background: #fff1c9;
  color: #a46f00;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.05;
}
.stage-age b { display: block; font-size: 23px; }
.stage.has-today .stage-age { background: var(--orange); color: #fff; }
.stage-body { flex: 1; min-width: 0; }
.stage-title { display: block; font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font: inherit; font-size: 13.5px; font-weight: 800; font-style: normal; padding: 7px 11px; border-radius: 999px; background: #f3efe2; color: var(--ink-2); border: 2px solid transparent; cursor: pointer; }
button.chip:active { transform: scale(.96); }
.chip.today { background: var(--orange); color: #fff; box-shadow: 0 3px 0 #d96a22; }
.chip.done { background: var(--green-l); color: var(--green-d); border-color: #bfe6b3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: -6px 0 14px; font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend .chip { padding: 3px 8px; font-size: 12px; box-shadow: none; cursor: default; }
.tick {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
}
.tick { font-size: 12px; color: var(--green-d); }
.stage.full .tick { background: var(--green); border-color: var(--green); color: #fff; font-size: 16px; }
.stage.full .tick::after { content: "✓"; }
.stage.part .tick { border-color: #bfe6b3; background: #f4fcef; }

/* Slide 4 – hasil */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1ecdc; padding: 5px; border-radius: 16px; margin-bottom: 12px; }
.tab { border: 0; background: none; font-size: 16px; font-weight: 600; padding: 10px; border-radius: 12px; color: var(--ink-2); cursor: pointer; }
.tab.on { background: #fff; color: var(--green-d); box-shadow: 0 2px 0 var(--line); }
.preview {
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(46, 58, 40, .16);
  margin-bottom: 14px;
  background: #fff;
}
.preview canvas { display: block; width: 100%; height: auto; touch-action: manipulation; }
.preview canvas:active { cursor: grabbing; }
.preview canvas[hidden] { display: none; }

.zoom { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; font-weight: 800; font-size: 14px; }
.zoom span { white-space: nowrap; }
.zoom input { flex: 1; accent-color: var(--green); }
.share { display: grid; gap: 12px; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dl-row .btn { font-size: 16px; padding: 14px 8px; }
.share + .note { margin-top: 14px; }

/* Modal kamera */
.cam-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #10160d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.cam-modal[hidden] { display: none; }
.cam-view {
  position: relative;
  width: min(92vw, 440px);
  aspect-ratio: 1;
  border-radius: 28px;
  overflow: hidden;
  background: #000;
}
.cam-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-view video.mirror { transform: scaleX(-1); }
.cam-guide {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  border: 4px dashed rgba(255,255,255,.75);
  box-shadow: 0 0 0 999px rgba(0,0,0,.25);
}
.cam-hint { color: #e9f3e4; margin: 0; font-weight: 700; text-align: center; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; width: min(92vw, 440px); }
.cam-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 22px; cursor: pointer; }
.shutter {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 6px solid #fff;
  background: var(--green);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(88,185,71,.45);
}
.shutter:active { transform: scale(.94); }
