* { box-sizing: border-box; }
html, body {
  /* Matikan pinch-zoom & double-tap-zoom bawaan browser di seluruh halaman.
     "manipulation" tetap izinkan scroll biasa, cuma buang gesture zoom-nya,
     jadi tulisan halaman tidak ikut membesar saat pinch di area kamera. */
  touch-action: manipulation;
}
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #222;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}
.wrap {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
h1 { margin: 0 0 0.25rem; color: #4a2f7d; }
.sub { margin: 0 0 1.5rem; color: #666; }
.field { margin-bottom: 1.5rem; }
.field label { display: block; margin-bottom: 0.4rem; font-weight: 600; color: #4a2f7d; }
.field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus { outline: 2px solid #667eea; border-color: #667eea; }
.video-box {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* cegah pinch di video diteruskan jadi pinch-zoom halaman */
}
video, #resultPreview img, #resultPreview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#preview {
  transform-origin: center center;
  will-change: transform;
}
.zoom-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.zoom-row input[type="range"] {
  flex: 1;
}
.zoom-label {
  color: #4a2f7d;
  font-size: 0.9rem;
  min-width: 2.2rem;
  text-align: center;
}
.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.btn {
  flex: 1;
  min-width: 120px;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  background: #eee;
  color: #333;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: #667eea; color: #fff; }
.btn.danger { background: #e14b4b; color: #fff; }
.status {
  margin-top: 1rem;
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: #4a2f7d;
  white-space: pre-wrap;
}
.result {
  margin-top: 1.5rem;
  border-top: 1px solid #eee;
  padding-top: 1rem;
}
.result h3 { margin: 0 0 0.75rem; }
#resultPreview {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}
.gallery {
  margin-top: 1.5rem;
  border-top: 1px solid #eee;
  padding-top: 1rem;
}
.gallery h3 { margin: 0 0 0.75rem; }
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
