:root {
  --bg: #ffffff;
  --text: #1c1c1e;
  --text-soft: #8e8e93;
  --accent: #1c1c1e;
  --accent-text: #ffffff;
  --surface: #f2f2f7;
  --border: #e5e5ea;
  --error: #d70015;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

[hidden] { display: none !important; }

.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- Pincode ---------- */
.pin-screen {
  justify-content: center;
  text-align: center;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  max-width: none;
}

.pin-inner {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pin-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 4px; }
.pin-title { font-size: 28px; font-weight: 700; }
.pin-subtitle { color: var(--text-soft); font-size: 16px; }

.pin-dots { display: flex; gap: 16px; margin: 16px 0 4px; }
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-soft);
  transition: background 0.15s, border-color 0.15s;
}
.pin-dot.filled { background: var(--text); border-color: var(--text); }

.pin-dots.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.pin-error {
  color: var(--error);
  font-size: 14px;
  min-height: 20px;
  visibility: hidden;
}
.pin-error.visible { visibility: visible; }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 14px;
  justify-content: center;
  margin-top: 8px;
}
.pin-pad button {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--surface);
  font-size: 26px;
  font-weight: 500;
  transition: background 0.1s;
}
.pin-pad button:active { background: var(--border); }
.pin-pad .pin-back { background: transparent; font-size: 22px; }

/* ---------- Home ---------- */
.app-header h1 { font-size: 26px; font-weight: 700; }
.app-subtitle { color: var(--text-soft); font-size: 15px; margin-top: 4px; }

.photo-zone {
  position: relative;
  display: block;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px dashed var(--border);
  overflow: hidden;
  cursor: pointer;
  min-height: 260px;
}

.photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.photo-icon { font-size: 36px; }
.photo-placeholder p { font-size: 17px; font-weight: 600; }
.photo-placeholder span { font-size: 14px; color: var(--text-soft); }

#photo-preview {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: #000;
}

.photo-zone:has(#photo-preview:not([hidden])) {
  border-style: solid;
  min-height: 0;
}

.photo-change {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 14px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ---------- Toggle ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  padding: 12px;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.seg-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---------- Prompt ---------- */
.prompt-field {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font: inherit;
  font-size: 16px;
  resize: none;
  background: var(--bg);
  color: var(--text);
}
.prompt-field:focus { outline: none; border-color: var(--text); }
.prompt-field::placeholder { color: var(--text-soft); }
.prompt-field-large { flex: 1; min-height: 220px; }

/* ---------- Knoppen ---------- */
.btn {
  width: 100%;
  padding: 17px;
  border-radius: 100px;
  font-size: 17px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:disabled { opacity: 0.3; transform: none; }
.btn-secondary { background: var(--surface); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-soft); }

/* ---------- Wachten ---------- */
.wait-screen { justify-content: center; text-align: center; }

.wait-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loader { display: flex; gap: 10px; }
.loader span {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  animation: pulse 1.2s ease-in-out infinite;
}
.loader span:nth-child(2) { animation-delay: 0.2s; }
.loader span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

#wait-title { font-size: 21px; font-weight: 700; }
.wait-hint { color: var(--text-soft); font-size: 15px; line-height: 1.5; }

.wait-error {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}
#wait-error-text { color: var(--error); font-size: 15px; }

/* ---------- Resultaat ---------- */
.result-screen { justify-content: center; }

.result-media {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.result-media img,
.result-media video {
  display: block;
  width: 100%;
  max-height: 60dvh;
  object-fit: contain;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
