
:root {
  --sky: #bde1f7;
  --water: #6893b6;
  --grass: #667850;
  --forest: #24301b;
  --stone: #8da7ac;
  --cloud: #e9f0f6;
  --text: #182016;
  --muted: #516156;
  --danger: #9b2c2c;
  --success: #1f6f3d;
  --shadow: 0 18px 40px rgba(36, 48, 27, 0.16);
  --radius: 24px;
  --header-height: 84px;
  --footer-height: 84px;
  --content-padding: 14px;
}
*,
*::before,
*::after { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  touch-action: manipulation;
}
body {
  min-height: 100dvh;
  height: var(--app-height, 100dvh);
  background: transparent;
}
img, video, canvas { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(233, 240, 246, 0.94), rgba(189, 225, 247, 0.9) 30%, rgba(104, 147, 182, 0.22)),
    linear-gradient(135deg, var(--cloud), var(--sky));
  background-attachment: fixed;
}
.app-shell {
  position: fixed;
  inset: 0;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  height: var(--header-height);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--content-padding) 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(233,240,246,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(141,167,172,.35);
}
.brand { display:flex; align-items:center; gap:10px; font-weight:700; min-width:0; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--water), var(--grass));
  box-shadow: 0 0 0 6px rgba(141,167,172,.25);
}
.brand-text { white-space: nowrap; }
.status-wrap { min-width: 0; text-align: right; }
.current-context {
  font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flow-progress {
  margin-top: 6px;
  display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap;
}
.flow-pill {
  min-width: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(36,48,27,.12);
}
.flow-pill.active { background: var(--forest); color: #fff; }
.flow-pill.done { background: rgba(36,48,27,.28); }

.pages {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  bottom: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.page {
  display: none;
  position: absolute;
  inset: 0;
  padding: 10px var(--content-padding);
  animation: pageFade .22s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page.active { display: block; }
@keyframes pageFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.card {
  width: min(100%, 760px);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(141,167,172,.28);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: min(100%, 320px);
  overflow: visible;
}
.start-card, .review-card, .success-card { justify-content: center; }
.page[data-kind="start"] .page-inner,
.page[data-kind="review"] .page-inner,
.page[data-kind="success"] .page-inner {
  align-items: center;
}
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-size: 12px; font-weight: 700; }
h1, h2, h3, p { margin: 0; }
h1, h2 { line-height: 1.15; }
.lead { font-size: 16px; }
.info-box {
  display:flex; flex-direction:column; gap:6px;
  padding: 12px 14px; border-radius: 18px; background: rgba(233,240,246,.9);
}
.info-content {
  flex: 1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(233,240,246,.78);
  overflow: hidden;
}
.label { font-weight: 700; font-size: 14px; }
.required-mark { color: var(--danger); }
.text-input,
.file-input,
.message-field {
  width: 100%;
  border: 1px solid rgba(141,167,172,.7);
  border-radius: 16px;
  background: rgba(255,255,255,.96);
  color: var(--text);
  padding: 14px;
}
.text-input:focus,
.file-input:focus,
.message-field:focus { outline: 2px solid rgba(104,147,182,.4); border-color: var(--water); }
.message-field {
  min-height: clamp(150px, 26vh, 230px);
  max-height: clamp(150px, 26vh, 230px);
  resize: none;
}
.helper { font-size: 13px; color: var(--muted); }
.meta-row {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  font-size: 12px; color: var(--muted);
}
.media-stage {
  position: relative;
  width: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(24,32,22,.96);
  border: 1px solid rgba(141,167,172,.4);
  min-height: clamp(320px, 48vh, 460px);
}
.media-stage video,
.media-stage img {
  width: 100%;
  height: clamp(320px, 48vh, 460px);
  object-fit: contain;
  background: #0d1210;
  object-position: center center;
}
.media-stage img[hidden],
.media-stage video[hidden] { display: none; }
.camera-overlay {
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(12,16,11,.46);
  padding: 18px;
}
.camera-overlay[hidden] { display: none; }
.camera-overlay-card {
  width: min(100%, 320px);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  padding: 16px;
  display:flex; flex-direction:column; gap:10px;
  text-align:center;
}
.btn-row {
  display:flex; gap:10px; flex-wrap:wrap;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
}
.btn-full { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--forest), var(--grass)); color: #fff; }
.btn-secondary { background: rgba(104,147,182,.16); color: var(--forest); }
.summary-stack {
  display:flex;
  flex-direction:column;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}
.summary-item {
  border-radius: 18px;
  background: rgba(233,240,246,.84);
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.summary-item img {
  width: 100%;
  border-radius: 16px;
  height: clamp(180px, 24vh, 260px);
  object-fit: contain;
  background: #0d1210;
}
.result-box {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
}
.result-box.success { background: rgba(31,111,61,.14); color: var(--success); }
.result-box.error { background: rgba(155,44,44,.12); color: var(--danger); }

.app-footer,
.footer-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 35;
  height: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
  padding: 10px var(--content-padding) calc(10px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  background: rgba(233,240,246,.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(141,167,172,.35);
}
.footer-btn,
.app-footer .footer-btn,
.footer-nav .footer-btn {
  appearance:none;
  border:none;
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  color: var(--forest);
  font-weight: 700;
  padding: 12px 8px;
}
.footer-btn-accent,
.footer-btn-primary {
  background: linear-gradient(135deg, var(--water), var(--grass));
  color: #fff;
}
.footer-btn:disabled {
  opacity: .42;
}

.scanner-modal[hidden] { display:none; }
.scanner-modal {
  position: fixed; inset: 0; z-index: 90;
}
.scanner-backdrop {
  position:absolute; inset:0; background: rgba(12,16,11,.56);
}
.scanner-sheet {
  position:absolute;
  left: 10px; right: 10px; top: max(12px, env(safe-area-inset-top, 0px) + 8px);
  bottom: max(12px, env(safe-area-inset-bottom, 0px) + 8px);
  border-radius: 24px;
  background: rgba(233,240,246,.97);
  box-shadow: var(--shadow);
  display:flex; flex-direction:column;
  overflow:hidden;
}
.scanner-head {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 16px 16px 10px;
}
.icon-btn {
  width: 40px; height: 40px; border:none; border-radius: 50%;
  background: rgba(104,147,182,.16); font-size: 26px; line-height: 1; cursor:pointer;
}
.scanner-stage {
  position: relative;
  flex: 1;
  margin: 0 16px;
  border-radius: 22px;
  overflow:hidden;
  background: #0d1210;
}
#scannerVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-frame {
  position:absolute; inset: 12% 10%;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 24px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.18);
}
.scanner-overlay {
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(0,0,0,.32);
  padding: 18px;
}
.scanner-overlay[hidden] { display:none !important; }
.scanner-overlay-card {
  width: min(100%, 320px);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  padding: 16px;
  display:flex; flex-direction:column; gap:10px;
  text-align:center;
}
.scanner-meta {
  padding: 14px 16px 16px;
  display:flex; flex-direction:column; gap:10px;
}
.manual-row {
  display:flex; gap:8px;
}
.manual-row .text-input { min-width: 0; flex:1; }

code { font-family: Consolas, monospace; font-size: .95em; }
.hidden { display:none !important; }

@media (max-width: 480px) {
  :root {
    --header-height: 78px;
    --footer-height: 80px;
    --content-padding: 12px;
  }
  .card { padding: 14px; gap: 10px; }
  .media-stage,
  .media-stage video,
  .media-stage img { min-height: clamp(260px, 39vh, 380px); height: clamp(260px, 39vh, 380px); }
  .footer-btn { font-size: 14px; }
}


.flow-action-row {
  margin-top: auto;
  padding-top: 4px;
}

.flow-next-btn {
  min-height: 52px;
}

.page-photo {
  padding-bottom: 18px;
}
.card-photo {
  min-height: auto;
}
.page-photo .page-inner {
  align-items: flex-start;
}
.page-photo .flow-action-row {
  margin-top: 0;
  padding-top: 6px;
}


.question-text {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 700;
}

.answer-list {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(36,48,27,.16);
  background: rgba(255,255,255,.72);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.answer-option input {
  width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
}

.answer-option span {
  font-size: 16px;
  line-height: 1.4;
}

.answer-option:has(input:checked) {
  border-color: rgba(104,147,182,.8);
  background: rgba(189,225,247,.45);
  box-shadow: 0 8px 24px rgba(36,48,27,.08);
}

.summary-answer {
  margin-top: 10px;
}

.text-input-code {
  letter-spacing: 0.3em;
  font-weight: 700;
  text-align: center;
}


.summary-grid {
  display: grid;
  gap: 12px;
}

.summary-media-wrap {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(24,32,22,.08);
  padding: 8px;
}

.preview-image,
.summary-item img {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  border-radius: 14px;
  background: #0d1210;
}

.summary-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(233,240,246,.82);
}

.summary-answer {
  line-height: 1.5;
}

.hidden {
  display: none !important;
}
