:root {
  --bg: #fdf7ed;
  --card: #fffaf2;
  --ink: #2c1b14;
  --accent: #b24c36;
  --accent-strong: #8f3a29;
  --ok: #216740;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, #ffe8cf 0, transparent 38%),
    radial-gradient(circle at 85% 80%, #ffd8ca 0, transparent 36%),
    var(--bg);
  min-height: 100vh;
}

.app-shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0.75rem 0.75rem 1rem;
}

.camera-card {
  background: linear-gradient(165deg, #fffdf8, var(--card));
  border: 1px solid #f1d3bc;
  border-radius: 1.1rem;
  padding: 0.75rem;
  box-shadow: 0 16px 40px rgba(104, 49, 31, 0.12);
}

#preview {
  width: 100%;
  border-radius: 0.9rem;
  background: #000;
  max-height: 75vh;
  object-fit: cover;
}

.controls {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.6rem;
}

button {
  font: inherit;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  background: #edd9c8;
  color: #2e1e17;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #cc684f);
  color: #fff;
  font-weight: 700;
}

button:active {
  transform: scale(0.99);
}

button:disabled {
  opacity: 0.5;
}

.toast-wrap {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 620px);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  border-radius: 0.8rem;
  border: 1px solid #f1d3bc;
  background: rgba(255, 250, 242, 0.97);
  box-shadow: 0 10px 28px rgba(61, 23, 12, 0.2);
  color: var(--ink);
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: auto;
}

.toast-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast-action-btn {
  border: 1px solid #d9bda8;
  background: #fff;
  color: #3a261d;
  border-radius: 999px;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  line-height: 1;
  white-space: nowrap;
  align-self: flex-start;
}

.toast-action-btn:active {
  transform: scale(0.98);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.ok {
  border-color: #9cc7b0;
  color: var(--ok);
}

.toast.error {
  border-color: #dfb1b6;
  color: #9a1b25;
}

.app-version {
  position: fixed;
  right: max(0.55rem, env(safe-area-inset-right));
  bottom: max(0.45rem, env(safe-area-inset-bottom));
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  opacity: 0.55;
  color: #5a4539;
  z-index: 900;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 699px) {
  body {
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    padding: 0.5rem;
  }

  .camera-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
  }

  #preview {
    flex: 1;
    min-height: 0;
    max-height: none;
    width: 100%;
  }

  .controls {
    margin-top: 0.55rem;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  #switchCameraBtn {
    order: 1;
  }

  #fallbackUploadBtn {
    order: 2;
  }

  #captureBtn {
    order: 3;
  }
}

@media (min-width: 700px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }
}
