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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --gray-50: #f8fafc;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* ── Header ── */
header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-logo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

.header-app-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--blue);
  text-align: right;
  line-height: 1.3;
}

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
}

/* ── Preview ── */
.preview-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  max-height: 56vw;    /* ~20% kleiner als vorher */
  max-width: 80%;
  align-self: center;
  width: 100%;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--gray-400);
  font-size: 0.9rem;
}

#canvas { display: none; }

#preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Absender E-Mail ── */
.sender-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sender-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sender-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sender-section input[type="email"] {
  flex: 1;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s;
}

.sender-section input[type="email"]:focus {
  border-color: var(--blue);
}

/* ── Nachricht ── */
.message-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-field textarea {
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--gray-800);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.message-field textarea:focus {
  border-color: var(--blue);
}

.saved-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Buttons ── */
.action-section {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary {
  flex: 1;
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary {
  flex: 1;
  background: #fff;
  color: var(--blue);
  border: 2px solid var(--blue);
}
.btn-secondary:hover { background: var(--blue-light); }

.send-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.target-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-light);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--blue-dark);
  font-weight: 500;
  word-break: break-all;
}

.btn-send {
  width: 100%;
  background: var(--green);
  color: #fff;
  padding: 16px;
  font-size: 1rem;
  border-radius: var(--radius);
}
.btn-send:hover { background: #15803d; }

.btn-ghost {
  width: 100%;
  background: transparent;
  color: var(--gray-600);
  font-size: 0.85rem;
  padding: 10px;
}
.btn-ghost:hover { background: var(--gray-200); }

/* ── Status ── */
.status {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}
.status.success { background: #dcfce7; color: #166534; }
.status.error   { background: #fee2e2; color: #991b1b; }

/* ── Camera Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

.modal-header h2 {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}

.close-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 30px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

.btn-capture {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.capture-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.1s;
}
.btn-capture:active .capture-inner { transform: scale(0.9); }

.flip-btn {
  position: absolute;
  bottom: 42px;
  right: 30px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

/* ── Erfolgs-Screen ── */
.success-screen {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 32px;
  text-align: center;
}

.success-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-content h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gray-800);
}

.success-content p {
  font-size: 1rem;
  color: var(--gray-600);
  line-height: 1.5;
}

.success-countdown {
  margin-top: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
  font-weight: 600;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Desktop ── */
@media (min-width: 640px) {
  .app {
    margin: 0 auto;
    padding: 0 0 60px;
  }
  header { padding: 20px 24px; }
  main { padding: 28px 24px; }
}
