/* Trang Chụp & thêm chi tiêu: body[data-step] chọn bước đang hiện */
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.capture { display: contents; }
.step { display: none; flex-direction: column; flex: 1; min-height: 0; }
.capture[data-step="camera"] .step-camera,
.capture[data-step="form"] .step-form,
.capture[data-step="done"] .step-done { display: flex; }

.app:has(.capture[data-step="camera"]) { background: var(--ink); color: #FFF; }
.app:has(.capture[data-step="camera"]) .scroll { padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }

.round-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; cursor: pointer; color: #FFF;
  transition: transform .3s var(--spring);
}
.round-btn:active { transform: scale(.9); }
.round-btn.big { width: 56px; height: 56px; }
.step-camera .glass { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); box-shadow: inset 0 1px 1px rgba(255, 255, 255, .4); }
.round-btn.light { background: var(--card); color: var(--ink); border: var(--line); box-shadow: 0 3px 0 var(--ink); }

/* ===== Bước 1: camera ===== */
.step-camera { gap: 16px; position: relative; }
.cam-top { display: flex; align-items: center; justify-content: space-between; }

.viewfinder { position: relative; flex: 1; min-height: 360px; border-radius: 32px; overflow: hidden; background: #262F52; }
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vf-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; font-weight: 700; color: rgba(255, 255, 255, .85); padding: 24px; }
.capture[data-cam="on"] .vf-empty { display: none; }

.corner { position: absolute; width: 40px; height: 40px; border: 4px solid var(--orange); animation: breathe 2.4s ease-in-out infinite; }
.corner.tl { top: 22px; left: 22px; border-right: 0; border-bottom: 0; border-top-left-radius: 16px; }
.corner.tr { top: 22px; right: 22px; border-left: 0; border-bottom: 0; border-top-right-radius: 16px; }
.corner.bl { bottom: 22px; left: 22px; border-right: 0; border-top: 0; border-bottom-left-radius: 16px; }
.corner.br { bottom: 22px; right: 22px; border-left: 0; border-top: 0; border-bottom-right-radius: 16px; }
@keyframes breathe { 50% { transform: scale(.9); opacity: .7; } }

.hint {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font-size: calc(13rem / 17); font-weight: 800;
  background: rgba(27, 35, 64, .55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

.cam-controls { display: flex; align-items: center; justify-content: space-around; padding: 4px 8px; }
.shutter { width: 84px; height: 84px; border-radius: 50%; padding: 6px; background: #FFF; transition: transform .3s var(--spring); }
.shutter:active { transform: scale(.9); }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--orange); border: 3px solid var(--ink); }

.flash-overlay { position: fixed; inset: 0; background: #FFF; opacity: 0; pointer-events: none; }
.capture.flashing .flash-overlay { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

/* ===== Bước 2: nhập ===== */
.step-form { gap: 16px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.form-head { display: flex; align-items: center; justify-content: space-between; }
.form-head h1 { font-size: 22px; font-weight: 800; }
.form-head .spacer { width: 44px; }

.preview {
  align-self: center; margin: 0; width: 190px; padding: 8px 8px 10px; border-radius: 20px; background: var(--card);
  border: var(--line); box-shadow: 0 5px 0 var(--ink);
  animation: drop .8s var(--spring) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-70px) rotate(-14deg) scale(1.15); } to { transform: rotate(-3deg); } }
.preview img, .shot-empty { width: 100%; height: 130px; border-radius: 12px; border: 2px solid var(--ink); object-fit: cover; display: block; }
.shot-empty { display: grid; place-items: center; background: var(--boba); color: var(--ink); }
.shot-empty svg { width: 48px; height: 48px; }
.capture:not([data-shot="yes"]) .shot, .capture[data-shot="yes"] .shot-empty { display: none; }
.preview figcaption { margin-top: 8px; text-align: center; font-size: calc(13rem / 17); font-weight: 800; }

.amount { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.amount label, .cats legend, .note span { font-size: calc(13rem / 17); font-weight: 800; color: var(--muted); }
.amount-row { display: flex; align-items: baseline; gap: 4px; }
.amount-row input {
  flex: 1; min-width: 0; border: 0; background: none; padding: 0; outline: none;
  font-size: 40px; font-weight: 800; color: var(--ink); line-height: 1.1;
}
.amount-row span { font-size: 28px; font-weight: 800; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick button {
  min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: calc(14rem / 17); font-weight: 800;
  background: var(--drink); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.quick .clear { background: var(--soft); }

.cats { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cats legend { padding: 0; margin-bottom: 8px; }
.cats label {
  position: relative; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 10px;
  border-radius: 14px; font-size: calc(13rem / 17); font-weight: 800; cursor: pointer;
  background: var(--card); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.cats label .i { width: 20px; height: 20px; }
.cats input { position: absolute; opacity: 0; }
.cats label:has(input:checked) { background: var(--c); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.cats label:has(input:focus-visible) { outline: 3px solid var(--orange); outline-offset: 2px; }

.note { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; }
.note input { border: 0; outline: none; background: none; padding: 0; font: inherit; font-size: max(16px, calc(16rem / 17)); /* < 16px thì iOS tự zoom khi gõ */ font-weight: 700; color: var(--ink); }
.note input::placeholder { color: #8C91A1; }

/* ===== Bước 3: xong ===== */
.step-done { align-items: center; justify-content: center; gap: 12px; text-align: center; position: relative; padding-bottom: 40px; }
.step-done h1 { font-size: 26px; font-weight: 800; max-width: 280px; line-height: 1.2; }
.mascot-big { animation: jump 1s var(--spring) both, bob 3s ease-in-out 1s infinite; transform-origin: 50% 90%; }
@keyframes jump { 0% { transform: scale(.3) translateY(80px); opacity: 0; } 60% { transform: scale(1.08) translateY(-12px); opacity: 1; } 100% { transform: none; } }
.done-amount { font-size: 40px; font-weight: 800; line-height: 1; }
.done-actions { margin-top: 24px; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.ghost { min-height: 52px; border-radius: 18px; font-weight: 800; color: var(--orange-ink); }

.rain { position: absolute; inset: -60px -20px 0; overflow: hidden; pointer-events: none; }
.rain i {
  position: absolute; top: -40px; left: var(--x); width: 26px; height: 26px; border-radius: 50%;
  background: var(--drink); border: 2.5px solid var(--ink); box-shadow: inset -3px -3px 0 #E8B400;
  animation: rain 1.8s cubic-bezier(.4, .1, .7, 1) var(--d) both;
}
@keyframes rain { to { transform: translateY(820px) rotateY(900deg); } }

/* ----- OCR: đọc chữ trong ảnh ----- */
.ocr-reading { display: flex; align-items: center; gap: 8px; margin: -4px 0 0; font-size: calc(14rem / 17); font-weight: 800; }
.ocr-reading img { animation: bob 1.2s ease-in-out infinite; }
.ocr-reading .dots { display: inline-flex; gap: 4px; }
.ocr-reading .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); animation: ocr-dot .9s ease-in-out infinite; }
.ocr-reading .dots i:nth-child(2) { animation-delay: .15s; }
.ocr-reading .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ocr-dot { 40% { transform: translateY(-5px); } }
.ocr-hint { color: var(--orange-ink); }

.ocr { flex: none; padding: 0; overflow: hidden; }
.ocr summary { padding: 14px 16px; min-height: 48px; font-weight: 800; cursor: pointer; }
.ocr summary span { font-size: calc(13rem / 17); color: var(--muted); }
.ocr ul { list-style: none; margin: 0; padding: 0 8px 8px; max-height: 260px; overflow-y: auto; }
.ocr li button { width: 100%; min-height: 44px; padding: 8px; border-radius: 10px; text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.ocr li button:active { background: var(--soft); }
@media (prefers-reduced-motion: reduce) { .ocr-reading img, .ocr-reading .dots i { animation: none; } }
