/* ─────────────────────────────────────────────────────────────────────────
   Post PWA — visual language from Fabi's Scan-App design v1 (2026-07-08).
   Warm, senior-friendly, calm. Nunito font, terracotta accent, cream palette.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* Warm palette */
  --bg-warm: #efe7db;
  --bg-warm-soft: #f6ece1;
  --bg-warm-lighter: #faf6f0;
  --bg-camera: #17140f;
  --bg-camera-panel: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-dark: #2a2320;
  --text-muted: #8a7d72;
  --text-cream-onDark: rgba(255, 255, 255, 0.85);

  /* Accents */
  --accent: #c25a3a;
  --accent-hover: #a5482d;
  --accent-soft: #f3b48f;
  --success: #2f6f4f;
  --danger: #c25a3a;

  /* Neutrals for cards / lines */
  --card: #fff;
  --card-border: #eee6db;
  --line: #d3ccc0;
  --line-soft: #e4dfd6;
  --btn-outline: #d8cec1;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-warm-soft);
  color: var(--text-dark);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.screen[hidden] { display: none; }

.screen--warm { background: var(--bg-warm-soft); color: var(--text-dark); }
.screen--sent { background: var(--bg-warm-soft); color: var(--text-dark); }
.screen--camera { background: var(--bg-camera); color: #fff; }

.screen-bottom {
  padding: 0 24px 32px;
}

/* ─── PIN screen ───────────────────────────────────────────────────────── */

.pin-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  gap: 12px;
}

.pin-icon {
  font-size: 56px;
  margin-bottom: 8px;
}

.pin-title {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-dark);
  text-align: center;
}

.pin-hint {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

#pin-input {
  width: 100%;
  max-width: 320px;
  padding: 22px;
  font-size: 42px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  text-align: center;
  letter-spacing: 16px;
  color: var(--text-dark);
  background: #fff;
  border: 2px solid var(--card-border);
  border-radius: 20px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

#pin-input:focus {
  border-color: var(--accent);
}

#pin-input::placeholder {
  color: var(--line);
  letter-spacing: 16px;
}

.error-inline {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 800;
  font-size: 15px;
}

/* ─── Camera / Foto screen ─────────────────────────────────────────────── */

.camera-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 30px 4px;
  gap: 16px;
  min-height: 0;
}

/* Viewfinder = clipped video + overlay corner brackets. The .viewfinder-clip
   inner container holds the video and clips it to a rounded rectangle; the
   corner brackets are direct children of .viewfinder and extend outside the
   clip using negative offsets (matches the design's guide-brackets look).
   Max-width bumped 260→340 per Fabi feedback — feels much more like a real
   camera app when the preview fills more of the screen. */
.viewfinder {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 210 / 290;
}

.viewfinder-clip {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #17140f;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.viewfinder-clip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.viewfinder-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  padding: 20px;
}

.viewfinder-fallback-icon {
  font-size: 56px;
}

.viewfinder-corner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 0 solid var(--accent-soft);
  border-width: 4px 0 0 4px;
  border-radius: 8px 0 0 0;
}
.viewfinder-corner.top-left { top: -10px; left: -10px; }
.viewfinder-corner.top-right { top: -10px; right: -10px; border-width: 4px 4px 0 0; border-radius: 0 8px 0 0; }
.viewfinder-corner.bottom-left { bottom: -10px; left: -10px; border-width: 0 0 4px 4px; border-radius: 0 0 0 8px; }
.viewfinder-corner.bottom-right { bottom: -10px; right: -10px; border-width: 0 4px 4px 0; border-radius: 0 0 8px 0; }

#preview-strip,
#queue-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  padding: 8px 14px;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}

#preview-strip {
  background: rgba(255, 255, 255, 0.14);
}

#queue-strip {
  background: rgba(194, 90, 58, 0.28);
}

.preview-strip-label,
.queue-strip-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.camera-bottom {
  padding: 8px 26px calc(34px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.camera-sub-hint {
  margin: 0;
  color: var(--text-cream-onDark);
  font-weight: 700;
  font-size: 15px;
}

.shutter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 82px;
  height: 82px;
  border-radius: 999px;
  background: #fff;
  border: 6px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s;
}

.shutter:active {
  transform: scale(0.94);
}

.shutter-inner {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: var(--accent);
}

.camera-actions {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 4px;
  margin-top: 8px;
}

.btn-text-light {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 15px;
  padding: 8px 4px;
  cursor: pointer;
}

.btn-text-light:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-text-light:not(:disabled):active {
  color: #fff;
}

/* ─── Prüfen / review screen ───────────────────────────────────────────── */

.review-inner {
  flex: 1;
  padding: 40px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.review-title {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text-dark);
  letter-spacing: -0.5px;
}

#review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.review-item {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(42, 35, 32, 0.12);
  border: 1px solid var(--card-border);
}

.review-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.review-item-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
}

.review-item-number {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 8px;
}

.review-sub {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 700;
}

.review-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-bottom: 12px;
}

.btn-text-muted {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 8px 4px;
  cursor: pointer;
  margin-top: 4px;
}
.btn-text-muted:active { color: var(--text-dark); }

/* ─── Overview screen ──────────────────────────────────────────────────── */

.overview-inner {
  flex: 1;
  padding: 32px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overview-title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  color: var(--text-dark);
  letter-spacing: -0.5px;
}

.overview-sub {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 700;
}

#overview-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
}

.overview-brief {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(42, 35, 32, 0.06);
}

.overview-brief-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 4px;
}

.overview-brief-title {
  font-weight: 800;
  font-size: 16px;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.overview-brief-sub {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
}

.overview-brief-delete {
  background: transparent;
  border: none;
  color: var(--danger);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
}
.overview-brief-delete:active { background: rgba(194, 90, 58, 0.15); }

.overview-brief-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.overview-brief-thumb {
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-warm);
  position: relative;
}

.overview-brief-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overview-brief-thumb-num {
  position: absolute;
  bottom: 3px;
  left: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-dark);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
}

.overview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

/* ─── Success multi list ───────────────────────────────────────────────── */

.success-multi-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.success-multi-list li {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-warm);
  font-weight: 800;
  font-size: 16px;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.success-multi-list li .cat-badge {
  font-size: 12px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Uploading screen ─────────────────────────────────────────────────── */

.uploading-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  gap: 20px;
  text-align: center;
}

.uploading-spinner {
  width: 76px;
  height: 76px;
  border: 8px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.uploading-title {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-dark);
}

.uploading-hint {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ─── Success screen ───────────────────────────────────────────────────── */

.success-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px 20px;
  gap: 8px;
  text-align: center;
}

.success-check {
  width: 104px;
  height: 104px;
  border-radius: 999px;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  box-shadow: 0 14px 30px rgba(47, 111, 79, 0.35);
  margin-bottom: 8px;
}

.success-title {
  margin: 26px 0 6px;
  font-weight: 900;
  font-size: 30px;
  color: var(--text-dark);
}

.success-hint {
  margin: 0 0 30px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text-muted);
}

.success-card {
  width: 100%;
  background: var(--card);
  border-radius: 22px;
  padding: 20px 22px;
  box-shadow: 0 10px 28px rgba(42, 35, 32, 0.08);
  text-align: left;
  margin-bottom: 12px;
}

.success-card--message { margin-bottom: 0; }

.success-card-label {
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.success-card-value {
  margin: 8px 0 0;
  font-weight: 800;
  font-size: 22px;
  color: var(--text-dark);
}

.success-card-message {
  margin: 12px 0 0;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.4;
  color: var(--text-dark);
}

/* ─── Error screen ─────────────────────────────────────────────────────── */

.error-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  gap: 16px;
  text-align: center;
}

.error-icon {
  font-size: 76px;
}

.error-title {
  margin: 0;
  font-weight: 900;
  font-size: 28px;
  color: var(--text-dark);
}

.error-message {
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 16px;
  max-width: 320px;
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */

.btn-primary,
.btn-secondary,
.btn-dark {
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 18px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--text-dark);
  border: 2px solid var(--btn-outline);
  padding: 18px;
}
.btn-secondary:active { background: var(--btn-outline); }

.btn-dark { background: var(--text-dark); color: #fff; }
.btn-dark:active { transform: scale(0.98); }

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ─── Larger screens keep phone-width feel ─────────────────────────────── */
@media (min-width: 600px) {
  .screen {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ─── Confirm modal ───────────────────────────────────────────────────────
   Warm replacement for native confirm(). Backdrop dims the whole viewport;
   the card floats in the middle with the same cream card style used
   elsewhere in the app so it doesn't feel like a foreign iOS dialog. */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  animation: confirm-fade-in 160ms ease-out;
}
.confirm-backdrop[hidden] { display: none; }

.confirm-card {
  background: var(--bg-warm-lighter);
  color: var(--text-dark);
  border-radius: 24px;
  padding: 28px 24px 20px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: confirm-pop-in 200ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.confirm-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 12px;
}

.confirm-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--text-dark);
}

.confirm-message {
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@keyframes confirm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes confirm-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
