:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b726d;
  --accent: #2f5d46;
  --accent-ink: #ffffff;
  --line: #e4dfd6;
  --danger: #b3261e;
  color-scheme: light;
}

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

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none;
  user-select: none;
}

[hidden] { display: none !important; }

h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }

button, label { font: inherit; }

.center { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.center-text { text-align: center; }
.muted { color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: 0; max-width: 320px; }
.logo { width: 72px; height: 72px; border-radius: 18px; }
#google-button { min-height: 44px; margin-top: 8px; }

#home { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

.bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 12px; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 0; cursor: pointer; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.primary, .secondary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 96px; border-radius: 18px; font-weight: 600; cursor: pointer;
}
.primary { background: var(--accent); color: var(--accent-ink); border: 0; }
.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.primary svg, .secondary svg { width: 30px; height: 30px; }
.primary:active, .secondary:active { transform: scale(0.98); }

.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width: 600px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.gallery li { position: relative; aspect-ratio: 1; background: var(--line); overflow: hidden; border-radius: 4px; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery li.pending img { opacity: 0.55; }
.gallery li.pending::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px;
  border: 3px solid rgba(255,255,255,0.9); border-top-color: transparent; border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.camera { position: fixed; inset: 0; background: #000; color: #fff; z-index: 10; display: flex; flex-direction: column; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.flash.on { opacity: 0.7; transition: none; }
.camera-error { position: absolute; inset: 0; margin: auto; height: fit-content; max-width: 300px; text-align: center; padding: 16px; }

.camera-top {
  position: relative; display: flex; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 0;
}
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.45); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.round svg { width: 22px; height: 22px; }
.round[aria-pressed="true"] { background: #ffd54a; color: #000; }

.camera-bottom {
  position: relative; margin-top: auto; background: linear-gradient(transparent, rgba(0,0,0,0.6) 30%);
  padding: 24px 0 calc(env(safe-area-inset-bottom) + 20px);
}
.shots { list-style: none; margin: 0 0 16px; padding: 0 16px; display: flex; gap: 6px; overflow-x: auto; min-height: 60px; }
.shots li { flex: none; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 2px solid #fff; position: relative; }
.shots img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shots button { position: absolute; inset: 0; background: none; border: 0; cursor: pointer; }

.camera-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 24px; }
.count { font-weight: 600; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: #fff;
  box-shadow: inset 0 0 0 3px #000; cursor: pointer;
}
.shutter:active { transform: scale(0.92); }
.done {
  justify-self: end; min-width: 84px; height: 44px; border-radius: 22px; border: 0;
  background: #ffd54a; color: #000; font-weight: 700; cursor: pointer;
}
.done:disabled { opacity: 0.4; }
