:root {
  --sky: #bde1f7;
  --water: #6893b6;
  --grass: #667850;
  --forest: #24301b;
  --stone: #8da7ac;
  --cloud: #e9f0f6;
  --text: #182016;
  --danger: #9b2c2c;
  --success: #1f6f3d;
  --shadow: 0 18px 40px rgba(36, 48, 27, 0.16);
  --radius: 24px;
  --header-height: 84px;
  --content-padding: 16px;
  --footer-height: 84px;
}

*,
*::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;
}

html {
  background:
    linear-gradient(180deg, rgba(233, 240, 246, 0.92), rgba(189, 225, 247, 0.88) 30%, rgba(104, 147, 182, 0.24)),
    linear-gradient(135deg, var(--cloud), var(--sky));
  background-attachment: fixed;
}

body {
  min-height: 100dvh;
  height: var(--app-height, 100dvh);
  position: relative;
  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.92), rgba(189, 225, 247, 0.88) 30%, rgba(104, 147, 182, 0.24)),
    linear-gradient(135deg, var(--cloud), var(--sky));
}

.app-shell {
  position: fixed;
  inset: 0;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  min-height: var(--header-height);
  padding: 18px var(--content-padding) 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(233, 240, 246, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(141, 167, 172, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 700;
}

.brand-mark {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--water), var(--grass));
  box-shadow: 0 0 0 6px rgba(141, 167, 172, 0.25);
}

.brand-text {
  white-space: nowrap;
}

.step-indicator {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 54%;
}

.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(36, 48, 27, 0.18);
  transition: transform 0.25s ease, background 0.25s ease, opacity 0.25s ease;
}

.step-dot.active {
  background: var(--forest);
  transform: scale(1.15);
}

.step-dot.is-complete {
  background: rgba(36, 48, 27, 0.42);
}

.pages {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: var(--footer-height);
  overflow: hidden;
}

.page {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 8px var(--content-padding) calc(var(--content-padding) + 6px);
  overflow: hidden;
  animation: pageFade 0.28s ease;
}

.page.active {
  display: block;
}

@keyframes pageFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-inner {
  width: min(780px, calc(100vw - (var(--content-padding) * 2)));
  height: 100%;
  margin: 0 auto;
  display: grid;
  align-items: stretch;
}

.card {
  width: 100%;
  height: 100%;
  min-width: 0;
  background: rgba(233, 240, 246, 0.86);
  border: 1px solid rgba(141, 167, 172, 0.35);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(7px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.glass {
  background: rgba(233, 240, 246, 0.72);
}

h1,
.card h2 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.84rem;
  color: rgba(24, 32, 22, 0.7);
}

.helper,
.status-text,
.feature-list,
.info-content,
.summary-content {
  line-height: 1.55;
}

.helper-tight {
  margin-top: 8px;
  margin-bottom: 0;
}

.label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.required-mark {
  color: var(--danger);
}

textarea,
.text-input,
.photo-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(36, 48, 27, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px 16px;
  color: var(--text);
}

textarea {
  resize: none;
  min-height: 160px;
  max-height: 36dvh;
}

.text-input {
  min-height: 50px;
}

textarea:focus,
.text-input:focus,
.photo-input:focus {
  outline: 2px solid rgba(104, 147, 182, 0.45);
  outline-offset: 1px;
}

.meta-row,
.nav-row,
.camera-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.meta-row {
  justify-content: space-between;
  margin-top: 8px;
  color: rgba(24, 32, 22, 0.75);
}

.nav-row {
  margin-top: 20px;
  justify-content: space-between;
}

.nav-row-center {
  justify-content: center;
}

.camera-actions {
  margin-top: 14px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  min-height: 48px;
  max-width: 100%;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  word-break: break-word;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--forest), var(--grass));
  color: #fff;
}

.btn-secondary {
  background: rgba(141, 167, 172, 0.18);
  color: var(--text);
  border: 1px solid rgba(36, 48, 27, 0.12);
}

.camera-frame {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: clamp(220px, 34dvh, 360px);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(36, 48, 27, 0.06);
  border: 1px solid rgba(36, 48, 27, 0.12);
}

.camera-preview,
.photo-preview,
.photo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  image-orientation: from-image;
}

.camera-preview {
  object-fit: contain;
  object-position: center center;
  background: rgba(255, 255, 255, 0.55);
}

.photo-preview {
  object-fit: contain;
  object-position: center center;
  background: rgba(255, 255, 255, 0.55);
}

.fallback-upload {
  margin-top: 16px;
}

.summary-stack {
  display: grid;
  gap: 16px;
}

.summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.summary-box {
  min-width: 0;
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(36, 48, 27, 0.1);
}

.summary-media-wrap {
  width: 100%;
  min-height: 180px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(36, 48, 27, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-media-wrap.is-empty {
  padding: 14px;
  align-items: flex-start;
  justify-content: flex-start;
}

.preview-image {
  width: 100%;
  height: 100%;
  min-height: 180px;
  max-height: 320px;
  object-fit: contain;
  object-position: center center;
  background: rgba(255, 255, 255, 0.55);
}

.summary-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.summary-content.muted {
  color: rgba(24, 32, 22, 0.65);
}

.review-form-block {
  margin-bottom: 16px;
}

.result-box {
  margin-top: 16px;
  border-radius: 18px;
  padding: 14px 16px;
}

.result-box.success {
  background: rgba(31, 111, 61, 0.12);
  border: 1px solid rgba(31, 111, 61, 0.28);
  color: var(--success);
}

.result-box.error {
  background: rgba(155, 44, 44, 0.1);
  border: 1px solid rgba(155, 44, 44, 0.22);
  color: var(--danger);
}

.success-card {
  text-align: center;
}

@media (min-width: 768px) {
  .card {
    padding: 28px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 96px;
    --content-padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .step-indicator {
    max-width: 100%;
    justify-content: flex-start;
  }

  .nav-row {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .camera-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .card {
    padding: 14px;
  }

  textarea {
    min-height: 120px;
    max-height: 24dvh;
  }

  .camera-frame {
    height: 28dvh;
    min-height: 210px;
  }

  .feature-list,
  .info-content,
  .helper,
  .status-text,
  .summary-content {
    font-size: 0.95rem;
  }

  h1,
  .card h2 {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }
}

@supports (height: 100dvh) {
  body,
  .app-shell {
    height: var(--app-height, 100dvh);
  }
}


/* Camera layout + overlay fix */
.camera-frame {
  display: grid;
  place-items: center;
  isolation: isolate;
}

.camera-preview,
.photo-preview,
.photo-canvas,
.camera-overlay {
  grid-area: 1 / 1;
}

.camera-preview,
.photo-preview {
  position: static;
  inset: auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  object-fit: contain;
  object-position: center center;
  background: rgba(255, 255, 255, 0.55);
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(24, 32, 22, 0.34);
  z-index: 3;
}

.camera-overlay[hidden] {
  display: none;
}

.camera-overlay-card {
  width: min(100%, 380px);
  border-radius: 20px;
  padding: 16px;
  text-align: center;
  background: rgba(233, 240, 246, 0.96);
  border: 1px solid rgba(141, 167, 172, 0.42);
  box-shadow: var(--shadow);
}

.camera-overlay-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.camera-overlay-text {
  margin: 0 0 14px;
  line-height: 1.45;
}

.camera-actions-below {
  margin-top: 14px;
}

.manual-open-btn {
  width: 100%;
}




/* v7 photo preview sizing fixes */
.camera-frame {
  height: clamp(300px, 44dvh, 460px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-preview,
.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  background: rgba(255, 255, 255, 0.55);
}

.camera-preview.is-live,
.photo-preview.is-filled {
  background: rgba(255, 255, 255, 0.55);
}

.camera-status {
  margin-top: 12px;
}

.camera-frame:not(.has-overlay) .camera-overlay {
  display: none;
}

@media (max-width: 640px) {
  .camera-frame {
    height: clamp(320px, 48dvh, 520px);
  }
}


/* v8 fixed footer + cleaner camera area */
.camera-status {
  display: none !important;
}

.camera-overlay[hidden],
.camera-frame:not(.has-overlay) .camera-overlay {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.camera-overlay {
  background: rgba(24, 32, 22, 0.58);
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px var(--content-padding) calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(233, 240, 246, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(141, 167, 172, 0.35);
}

.footer-btn {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 10px 8px;
  background: rgba(141, 167, 172, 0.18);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.footer-btn-primary {
  background: linear-gradient(135deg, var(--forest), var(--grass));
  color: #fff;
}

.footer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  :root {
    --footer-height: 92px;
  }

  .app-footer {
    gap: 6px;
    padding-inline: 12px;
  }

  .footer-btn {
    font-size: 0.92rem;
    padding-inline: 4px;
  }
}


.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, 0.16);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.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, 0.8);
  background: rgba(189, 225, 247, 0.45);
  box-shadow: 0 8px 24px rgba(36, 48, 27, 0.08);
}

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


.summary-box-flow {
  background: rgba(104, 147, 182, 0.08);
}
