/* ── App shell (landing page) ───────────────────────────── */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #f4f4f5;
  color: #18181b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
}
.app-shell h1 {
  font-size: 28px;
  margin: 0 0 12px;
}
.app-shell .subtitle {
  color: #525252;
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 24px;
}
.launch-btn {
  display: inline-block;
  background: #2a7e3a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 16px 28px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.launch-btn:active { background: #1f5e2a; }
.launch-btn:disabled { background: #999; cursor: not-allowed; }
.diag {
  margin: 20px auto 0;
  font-family: monospace;
  font-size: 12px;
  color: #555;
  white-space: pre-line;
  text-align: left;
  max-width: 360px;
}
.hint {
  margin-top: 28px;
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

/* ── Fullscreen capture modal ──────────────────────────── */
.fpc-fullscreen {
  position: fixed; inset: 0;
  background: #000;
  z-index: 999999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;          /* Block all browser gestures inside modal */
  overscroll-behavior: contain;
}
.fpc-fullscreen video,
.fpc-fullscreen img.fpc-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.fpc-fullscreen video.fpc-cover { object-fit: cover; }

.fpc-detect {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.fpc-detect-poly, .fpc-detect-circle {
  fill: rgba(59, 130, 246, 0.10);
  stroke: #3b82f6;
  stroke-width: 4;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.18s;
}
.fpc-detect-poly.fpc-ready,
.fpc-detect-circle.fpc-ready { stroke: #22c55e; fill: rgba(34,197,94,0.12); }

.fpc-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  color: white;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
  z-index: 10;
}
.fpc-text-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 6px;
  font-family: inherit;
  min-width: 72px;
}
.fpc-text-btn.fpc-right { text-align: right; }
.fpc-status {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fpc-mode-bar {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 60px));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  z-index: 10;
}
.fpc-mode-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.fpc-mode-btn.fpc-active {
  background: rgba(255, 255, 255, 0.95);
  color: #111;
}

.fpc-shutter {
  position: absolute;
  bottom: 32px;
  bottom: max(32px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: white;
  border: 5px solid white;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.55), 0 4px 18px rgba(0,0,0,0.4);
  cursor: pointer;
  padding: 0;
  z-index: 10;
  transition: transform 0.08s, background 0.1s;
}
.fpc-shutter:active { transform: translateX(-50%) scale(0.93); background: #e5e5e5; }
.fpc-shutter:disabled { opacity: 0.45; cursor: not-allowed; }
@media (orientation: landscape) {
  .fpc-shutter {
    bottom: 50%;
    left: auto;
    right: 32px;
    right: max(32px, env(safe-area-inset-right));
    transform: translateY(50%);
  }
  .fpc-shutter:active { transform: translateY(50%) scale(0.93); }
}

.fpc-bottom-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 18px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  z-index: 10;
}
.fpc-action-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}
.fpc-btn {
  flex: 1;
  padding: 14px 16px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.fpc-btn-primary   { background: #2a7e3a; color: white; }
.fpc-btn-primary:disabled { background: #555; cursor: not-allowed; }
.fpc-btn-secondary { background: rgba(255,255,255,0.15); color: white; }
.fpc-btn-danger    { background: #b91c1c; color: white; }

.fpc-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 3px;
}
.fpc-toggle-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.fpc-toggle-btn.fpc-active {
  background: #2a7e3a;
  color: white;
}
.fpc-process-info {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.fpc-warning {
  background: rgba(250, 204, 21, 0.18);
  border: 1px solid #facc15;
  color: #facc15;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

/* ── Edit screen (rotate / crop) ───────────────────────────── */
.fpc-edit-stage {
  position: absolute;
  top: max(60px, env(safe-area-inset-top) + 50px);
  left: 0; right: 0;
  bottom: 220px;
  bottom: calc(220px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}
.fpc-edit-img {
  display: block;
  transform-origin: center center;
  transition: transform 0.05s linear;
  will-change: transform;
}
.fpc-edit-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.fpc-edit-quarters {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.fpc-edit-quarter {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-width: 96px;
}
.fpc-edit-quarter:active { background: rgba(255,255,255,0.28); }
.fpc-fine-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fpc-fine-slider {
  flex: 1;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.fpc-fine-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}
.fpc-fine-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: white;
  border: 2px solid #2a7e3a;
  margin-top: -9px;
  cursor: pointer;
}
.fpc-fine-slider::-moz-range-track {
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}
.fpc-fine-slider::-moz-range-thumb {
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: white;
  border: 2px solid #2a7e3a;
  cursor: pointer;
}
.fpc-fine-readout {
  color: white;
  font-size: 13px;
  font-family: monospace;
  min-width: 56px;
  text-align: right;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.fpc-edit-reset {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  align-self: center;
}

.fpc-toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  z-index: 9999999;
  padding: 12px 18px;
  border-radius: 6px;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: fpc-slide-in 0.2s ease-out;
}
.fpc-toast.fpc-success { background: #2a7e3a; }
.fpc-toast.fpc-error   { background: #b91c1c; }
.fpc-toast.fpc-info    { background: #1d4ed8; }
@keyframes fpc-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
