/* Gravida capture coach v2 — Atelier-warm palette */
:root {
  --beige: #f0ece2;
  --beige-soft: #faf8f4;
  --green: #1f2a1f;
  --green-soft: #3a4a3a;
  --gold: #8a7a5a;
  --rose: #d4a59a;
  --danger: #b85450;
  --ok: #5a8a5a;
  --warn: #d49a4f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--beige-soft);
  color: var(--green);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: block; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.brand { font-family: Georgia, serif; font-size: 26px; letter-spacing: 0.5px; color: var(--green); margin-bottom: 8px; }
.step-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gold); font-weight: 600; margin-bottom: 8px; }

h1 { font-family: Georgia, serif; font-size: 34px; font-weight: 400; line-height: 1.2; margin-bottom: 12px; }
h2 { font-family: Georgia, serif; font-size: 28px; font-weight: 400; line-height: 1.2; margin-bottom: 12px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.subtitle { font-size: 15px; color: var(--green-soft); line-height: 1.5; margin-bottom: 24px; }
.hint { font-size: 12px; color: var(--gold); margin-top: 16px; line-height: 1.4; text-align: center; }

.info-card { background: var(--beige); border-radius: 12px; padding: 18px 20px; margin-bottom: 20px; }
.info-card ul, .info-card ol { padding-left: 20px; font-size: 14px; line-height: 1.6; }
.info-card li { margin-bottom: 4px; }
.info-card p { font-size: 14px; line-height: 1.6; }

/* Buttons */
.btn { display: block; width: 100%; padding: 16px 20px; border: none; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.15s; margin-bottom: 10px; text-align: center; }
.btn.primary { background: var(--green); color: var(--beige-soft); }
.btn.primary:hover { background: var(--green-soft); }
.btn.primary:disabled { background: #c8c0a8; color: #fff; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--green-soft); border: 1px solid #d8cfb8; }
.btn.ghost.danger { color: var(--danger); border-color: var(--danger); opacity: 0.8; }

/* Checklist */
.checklist { margin-bottom: 24px; }
.check-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid #e8e2d2; border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-size: 14px; line-height: 1.4; user-select: none; transition: background 0.15s; }
.check-item:has(input:checked) { background: var(--beige); border-color: var(--gold); }
.check-item input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--green); cursor: pointer; }

/* Ring overview cards (NEW) */
.ring-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid #e8e2d2;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 12px;
}
.ring-num {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green);
  color: var(--beige-soft);
  font-family: Georgia, serif;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.ring-body h3 { color: var(--green); text-transform: none; letter-spacing: 0; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.ring-body p { font-size: 14px; line-height: 1.5; color: var(--green-soft); margin-bottom: 4px; }
.ring-body .ring-explain { font-size: 12px; color: var(--gold); font-style: italic; }

/* ============== Capture screen ============== */
.capture-screen { position: fixed; inset: 0; background: #000; display: none; }
.capture-screen.active { display: block; }

/* Landscape required overlay */
.rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.92);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
  transition: opacity 0.3s;
}
.rotate-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.rotate-icon {
  animation: rotate-pulse 1.6s ease-in-out infinite;
  transform-origin: center;
}
@keyframes rotate-pulse {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(-90deg); }
  60% { transform: rotate(-90deg); }
}
.rotate-title {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}
.rotate-text {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  max-width: 320px;
  line-height: 1.5;
}

/* Chrome auto-rotates the camera stream based on phone orientation,
   so the video element just needs to fill the viewport. */
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.overlay { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; z-index: 2; }
.overlay > * { pointer-events: auto; }

/* Top HUD with ring info + progress arc */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
  color: #fff;
  gap: 12px;
}

.ring-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.ring-name { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; opacity: 0.75; }
.ring-height { font-size: 17px; font-weight: 700; }
.ring-tilt { font-size: 13px; font-weight: 600; color: var(--rose); }
.ring-explain-hud { font-size: 11px; opacity: 0.75; line-height: 1.3; }

/* Coverage radar — 3 concentric rings with 40 segments each */
.coverage-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  background: rgba(0,0,0,0.55);
  padding: 8px 10px 6px;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
#coverage-svg {
  display: block;
}
.cov-seg {
  fill: rgba(255,255,255,0.14);
  stroke: rgba(0,0,0,0.4);
  stroke-width: 0.4;
  transition: fill 0.2s;
}
.cov-seg.cov-r0 { fill: rgba(212, 165, 154, 0.16); } /* chest — rose */
.cov-seg.cov-r1 { fill: rgba(255, 255, 255, 0.14); } /* navel — white */
.cov-seg.cov-r2 { fill: rgba(154, 192, 154, 0.18); } /* knee — green */
.cov-seg.covered.cov-r0 { fill: #d4a59a; }
.cov-seg.covered.cov-r1 { fill: #ffffff; }
.cov-seg.covered.cov-r2 { fill: #9ac09a; }
.cov-seg.active-ring { stroke: rgba(255,255,255,0.85); stroke-width: 0.6; }
.cov-cursor {
  stroke: #ffd75f;
  stroke-width: 1.5;
  stroke-linecap: round;
  transform-origin: 0 0;
  transition: transform 0.08s linear;
  filter: drop-shadow(0 0 2px rgba(255, 215, 95, 0.85));
}
#cov-count {
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.coverage-legend {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 9px;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.cov-leg-row { display: flex; align-items: center; gap: 3px; }
.cov-leg-row .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cov-leg-row .dot.r1 { background: #d4a59a; }
.cov-leg-row .dot.r2 { background: #efe4c4; }
.cov-leg-row .dot.r3 { background: #ffffff; }
.cov-leg-row .dot.r4 { background: #9ac09a; }

/* Body outline frame */
.frame-outline {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.frame-outline::before {
  content: '';
  width: 38%;
  height: 72%;
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 50% / 32%;
}

/* Coverage hint badge — appears just below the radar when stuck on a covered segment */
.coverage-hint {
  position: absolute;
  top: 196px;
  right: 14px;
  background: rgba(212, 165, 154, 0.96);
  color: var(--green);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(-4px);
  z-index: 4;
  white-space: nowrap;
  animation: hint-pulse 1.5s ease-in-out infinite;
}
.coverage-hint.visible { opacity: 1; transform: translateY(0); }
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 3px 10px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 16px rgba(212, 165, 154, 0.7); }
}

/* Manual next-ring button — appears when ≥22 segments covered */
.btn-next-ring {
  position: absolute;
  top: 232px;
  right: 14px;
  background: var(--gold);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  z-index: 5;
}
.btn-next-ring.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.btn-next-ring:active {
  transform: scale(0.96);
}

/* Debug toggle (small "i" icon, bottom-left of capture screen) */
.debug-toggle {
  position: absolute;
  bottom: 134px;
  left: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.25);
  font-family: Georgia, serif;
  font-size: 14px;
  font-style: italic;
  cursor: pointer;
  z-index: 6;
  padding: 0;
  line-height: 1;
}
.debug-overlay.hidden { display: none; }

/* Tilt meter */
.tilt-meter {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 86%;
  max-width: 380px;
  background: rgba(0,0,0,0.55);
  border-radius: 14px;
  padding: 10px 14px;
}
.tilt-status {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin-bottom: 6px;
  transition: color 0.2s;
}
.tilt-status.ok {
  color: #1a3d1a;
  background: #6fdc6f;
  padding: 6px 14px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  display: inline-block;
  margin: 0 auto 6px;
  box-shadow: 0 0 14px rgba(111, 220, 111, 0.6);
  animation: tilt-ok-pulse 1.4s ease-in-out infinite;
}
@keyframes tilt-ok-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(111, 220, 111, 0.6); }
  50% { box-shadow: 0 0 22px rgba(111, 220, 111, 0.95); }
}
.tilt-status.warn { color: var(--rose); }
.tilt-status.warn-flash { animation: warn-pulse 0.6s ease-out; }
@keyframes warn-pulse { 0%, 100% { background: transparent; } 50% { background: rgba(212, 165, 154, 0.3); } }

.tilt-track {
  position: relative;
  height: 22px;
  background: rgba(255,255,255,0.15);
  border-radius: 11px;
  overflow: hidden;
}
.tilt-target {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 33%;
  width: 34%;
  background: rgba(164, 216, 164, 0.28);
}
.tilt-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 8px;
  background: #fff;
  border-radius: 4px;
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.08s linear;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}
.tilt-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.6);
}

/* Bottom HUD */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 26px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  color: #fff;
}
.btn-cancel { background: rgba(255,255,255,0.15); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }

.btn-capture {
  width: 64px; height: 64px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.18);
  cursor: pointer; position: relative;
  transition: transform 0.1s ease;
}
.btn-capture:active { transform: scale(0.92); background: rgba(255,255,255,0.5); }
.btn-capture::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255,255,255,0.5); }

.total-count { font-size: 14px; font-weight: 600; background: rgba(0,0,0,0.4); padding: 6px 14px; border-radius: 20px; }
.total-count .muted { opacity: 0.55; font-weight: 400; }

/* Debug overlay — live sensor values */
.debug-overlay {
  position: absolute;
  bottom: 92px;
  left: 14px;
  right: 14px;
  background: rgba(0,0,0,0.55);
  color: #cfc;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.4;
  letter-spacing: 0.3px;
  pointer-events: none;
}

/* Ring transition banner */
.ring-banner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--green);
  color: #fff;
  padding: 22px 28px;
  border-radius: 14px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: banner-in 0.3s ease-out;
  max-width: 90%;
}
.ring-banner h3 { color: var(--rose); margin-bottom: 6px; font-size: 11px; }
.ring-banner p { font-size: 16px; margin-bottom: 6px; }
.ring-banner small { display: block; font-size: 12px; opacity: 0.8; margin-bottom: 14px; }
.banner-btn {
  background: var(--rose); color: var(--green); border: none;
  padding: 14px 36px; border-radius: 10px; font-size: 18px;
  font-weight: 700; cursor: pointer; letter-spacing: 0.05em;
  margin-top: 8px;
}
.ring-banner .banner-help {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.4;
  margin: 12px 0;
  max-width: 280px;
}
@keyframes banner-in {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Countdown overlay (3-2-1-GO before continuous capture) */
.countdown-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 140px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,0.7);
  z-index: 11;
  pointer-events: none;
  animation: countdown-pulse 1s ease-out infinite;
}
@keyframes countdown-pulse {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.15); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Capture flash */
.flash-overlay {
  position: absolute; inset: 0; background: #fff;
  opacity: 0.7; z-index: 5; pointer-events: none;
  animation: flash 0.22s ease-out forwards;
}
@keyframes flash { from { opacity: 0.7; } to { opacity: 0; } }

/* Review screen */
.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}
.thumbnail-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 6px; background: var(--beige);
}

/* Details section on review screen */
.details-section {
  background: #fff;
  border: 1px solid #e8e2d2;
  border-radius: 12px;
  padding: 18px 18px 14px;
  margin-bottom: 24px;
}
.details-section h3 {
  color: var(--green);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}
.details-section h3 .muted {
  color: var(--gold);
  font-weight: 400;
  font-size: 13px;
}
/* Required close-up cards */
.required-section h3 .muted {
  font-variant-numeric: tabular-nums;
}
.required-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.required-group h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 0 0 8px;
  font-weight: 600;
}
.required-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.shot-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e8e2d2;
  border-radius: 10px;
  background: var(--beige-soft);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.shot-card:hover {
  border-color: var(--gold);
}
.shot-card.captured {
  border-color: #6b8a6b;
  background: #f4f7f1;
}
.shot-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #fff;
  border: 1px dashed var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.shot-card.captured .shot-thumb {
  border-style: solid;
  border-color: #6b8a6b;
}
.shot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shot-icon {
  font-size: 22px;
  opacity: 0.5;
}
.shot-check {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6b8a6b;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}
.shot-text {
  flex: 1;
  min-width: 0;
}
.shot-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 2px;
}
.shot-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--green-soft);
}
.shot-retake {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.shot-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.upload-blocker-msg {
  text-align: center;
  font-size: 13px;
  color: var(--gold);
  margin: -8px 0 16px;
}
button.btn.primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.detail-list {
  margin-bottom: 10px;
}
.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f0ece2;
}
.detail-row:last-child { border-bottom: none; }
.detail-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--beige);
  flex-shrink: 0;
}
.detail-note {
  flex: 1;
  border: 1px solid #e8e2d2;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--beige-soft);
  color: var(--green);
  min-width: 0;
}
.detail-note:focus {
  outline: none;
  border-color: var(--gold);
}
.detail-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.detail-remove:hover {
  background: var(--gold);
  color: #fff;
}
.detail-add-btn {
  width: 100%;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 0;
  padding: 12px;
  font-size: 14px;
  background: var(--beige);
  border: 1px dashed var(--gold);
  color: var(--green);
  display: block;
  border-radius: 10px;
  cursor: pointer;
}
.detail-add-btn:hover {
  background: var(--beige-soft);
}

/* Upload progress */
.upload-progress { margin: 32px 0; }
.progress-bar {
  width: 100%; height: 8px;
  background: var(--beige);
  border-radius: 4px; overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--green);
  transition: width 0.3s ease;
}
.progress-text { text-align: center; font-size: 13px; color: var(--green-soft); }
