:root {
  --bg: #f6f2e9;
  --panel: #ffffff;
  --panel-2: #ece6d6;
  --text: #2b2a26;
  --muted: #7a7566;
  --accent: #3f6b4f;
  --accent-text: #ffffff;
  --ok: #3f6b4f;
  --border: #ddd5c2;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100%;
}

.topbar {
  text-align: center;
  padding: 24px 16px 8px;
}
body.hide-header .topbar { display: none; }
.topbar h1 { margin: 0 0 6px; font-size: 1.6rem; }
.privacy-note {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 0.85rem;
}

#app {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.step { display: none; }
.step.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 { text-align: center; font-size: 1.2rem; margin: 8px 0 18px; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 13px 26px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
  width: 100%;
  margin-top: 10px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn[hidden] { display: none; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.status-text { text-align: center; color: var(--muted); font-size: 0.9rem; }

.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}
.frame-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  border: 2px solid var(--border);
  text-align: center;
}
.frame-card.selected { border-color: var(--accent); }
.frame-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}
.frame-card .frame-name { margin-top: 8px; font-size: 0.9rem; font-weight: 600; }

.camera-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.camera-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
}
#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 4px 20px rgba(0,0,0,0.6);
  pointer-events: none;
}
.flash {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
}
.flash.on { opacity: 1; transition: opacity .08s ease; }
.flash.off { opacity: 0; transition: opacity .35s ease; }

.shot-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.shot-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.shot-indicator .dot.done { background: var(--ok); }

.camera-actions { max-width: 480px; margin: 14px auto 0; }

.pose-panel {
  width: 100%;
  max-width: 480px;
}
.pose-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.pose-card {
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.pose-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.pose-card .pose-label {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px;
}

.shots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 560px;
  margin: 0 auto 8px;
}
.shot-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid var(--border);
  background: var(--panel);
}
.shot-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; transform: scaleX(-1); }
.shot-card.selected { border-color: var(--accent); }
.shot-card .badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
}
.shot-card.selected .badge { display: flex; }

.result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
  background: var(--panel);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  text-align: center;
}
#strip-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: min(280px, 100%);
  max-height: 50vh;
  border-radius: 8px;
}
.bundle-list { color: var(--muted); font-size: 0.9rem; line-height: 1.9; padding: 0; list-style: none; }

@media (min-width: 720px) {
  .frame-grid { grid-template-columns: repeat(4, 1fr); }
  .camera-layout { flex-direction: row; align-items: flex-start; justify-content: center; }
  .camera-wrap { flex: 1 1 480px; }
  .pose-panel { flex: 0 0 300px; max-width: 300px; }
  .camera-actions, .btn { width: auto; }
  .camera-actions { display: flex; gap: 10px; justify-content: center; }
  #step-frame .btn, #step-select .btn { max-width: 320px; margin-left: auto; margin-right: auto; display: block; }
}
