:root {
  color-scheme: light;
  font-family: Inter, Arial, sans-serif;
  --text: #0f1720;
  --muted: #496072;
  --border: #cde4f7;
  --accent: #18a84a;
  --accent-strong: #1e88e5;
  --accent-soft: #eef8ff;
  --card: rgba(255, 255, 255, 0.94);
  --shadow: 0 18px 40px rgba(30, 136, 229, 0.12);
  --top-safe: max(12px, env(safe-area-inset-top));
  --bottom-safe: max(18px, env(safe-area-inset-bottom));
  --side-safe: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(126, 231, 160, 0.35), transparent 24%),
    radial-gradient(circle at bottom right, rgba(30, 136, 229, 0.16), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #eef8ff 46%, #f3fff5 100%);
  color: var(--text);
  overflow: hidden;
}
body { display: flex; justify-content: center; }
button, input { font: inherit; }
button { border: 0; border-radius: 18px; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.app-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  padding: calc(var(--top-safe) + 8px) var(--side-safe) calc(var(--bottom-safe) + 14px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.screen-stack { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  padding-bottom: 8px;
  gap: 12px;
  align-content: start;
}
.screen.active { display: grid; }
.screen.video-screen { grid-template-rows: auto 1fr auto auto; }
.card, .hero-card, .media-shell, .nav-shell, .barcode-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 14px;
}
.hero-card { border-top: 4px solid var(--accent); text-align: center; }
.logo { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto 10px; }
.hero-card h1, .screen-title {
  margin: 0;
  font-size: clamp(24px, 6vw, 32px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}
.hero-card p, .screen-subtitle, .instruction-text, .status-note, .small-text {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.status-pill {
  min-height: 70px;
  padding: 11px 10px;
  border-radius: 18px;
  background: #f8fcff;
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}
.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #425466;
}
.value { font-size: 13px; line-height: 1.3; font-weight: 800; color: var(--text); }
.screen-head { display: grid; gap: 4px; }
.step-chip {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.preview-card { padding: 12px; }
.preview-shell { display: grid; gap: 10px; justify-items: center; }
.sticker-preview {
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 10px rgba(255,255,255,0.34);
}
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.preset-card {
  text-align: left;
  min-height: 108px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 6px;
  box-shadow: 0 10px 24px rgba(30, 136, 229, 0.08);
}
.preset-card.active {
  background: linear-gradient(180deg, #ffffff 0%, #eef8ff 100%);
  border-color: #91ccff;
  box-shadow: 0 12px 28px rgba(30, 136, 229, 0.16);
}
.preset-card strong { font-size: 15px; line-height: 1.25; }
.preset-card span { font-size: 12px; line-height: 1.45; color: var(--muted); }
.instruction-card {
  background: linear-gradient(180deg, #f7fcff 0%, #ffffff 100%);
  border-left: 4px solid var(--accent-strong);
}
.choice-row, .action-row, .video-action-row { display: grid; gap: 10px; }
.choice-row, .action-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.video-action-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-btn, .action-btn, .nav-btn {
  min-height: 58px;
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 900;
  border-radius: 18px;
}
.choice-btn, .nav-btn.secondary, .action-btn.secondary {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}
.choice-btn.active, .nav-btn.primary, .action-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 10px 24px rgba(30, 136, 229, 0.2);
}
.action-btn.success { color: #093016; background: linear-gradient(135deg, #8df5ae 0%, #3fd77a 100%); }
.camera-shell, .video-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: #071018;
}
.camera-shell { aspect-ratio: 1 / 1; }
.video-shell { min-height: 100%; height: 100%; }
.media-video, .camera-video, .video-playback, .inactive-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.camera-video, .media-video { transform: scaleX(-1); transform-origin: center; }
.camera-overlay, .video-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7,16,24,0.24) 0%, rgba(7,16,24,0.03) 24%, rgba(7,16,24,0.07) 74%, rgba(7,16,24,0.24) 100%);
}
.camera-badge-row, .video-badge-row {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(7,16,24,0.52);
  border: 1px solid rgba(255,255,255,0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}
.inactive-cover {
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7,16,24,0.7);
  color: #fff;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  z-index: 3;
}
.inactive-cover.hidden { display: none !important; }
.video-status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: rgba(7,16,24,0.58);
}
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  color: #fff;
  font-size: 72px;
  font-weight: 900;
  text-shadow: 0 12px 32px rgba(0,0,0,0.44);
  pointer-events: none;
}
.countdown.hidden, .hidden { display: none !important; }
.review-layout { display: grid; gap: 12px; }
.review-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.review-panel { background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,252,255,0.98) 100%); }
.review-bright { background: linear-gradient(180deg, #ffffff 0%, #f3fff5 100%); }
.review-video {
  width: 100%;
  min-height: 220px;
  border-radius: 24px;
  background: #071018;
  border: 1px solid var(--border);
  object-fit: cover;
}
.review-empty {
  min-height: 220px;
  border-radius: 24px;
  background: linear-gradient(180deg, #f8fcff 0%, #ffffff 100%);
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.nav-shell { flex: 0 0 auto; display: grid; gap: 10px; }
.nav-dots { display: flex; justify-content: center; gap: 8px; }
.nav-dot { width: 10px; height: 10px; border-radius: 50%; background: #c6dcee; }
.nav-dot.active {
  width: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}
.nav-row, .overlay-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.barcode-overlay, .saving-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(var(--top-safe) + 12px) var(--side-safe) calc(var(--bottom-safe) + 12px);
  background: rgba(7,16,24,0.62);
  backdrop-filter: blur(4px);
}
.barcode-overlay.visible, .saving-overlay.visible { display: flex; }
.barcode-panel { width: min(100%, 440px); text-align: center; }
.barcode-panel h2 {
  margin: 0;
  font-size: clamp(24px, 6vw, 30px);
  line-height: 1.04;
}
.barcode-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.barcode-id {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: #f8fcff;
  border: 1px solid var(--border);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.barcode-svg-wrap {
  margin-top: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 14px 10px;
}
.barcode-svg-wrap svg { width: 100%; height: 120px; display: block; }
.spinner {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 6px solid #dceeff;
  border-top-color: var(--accent-strong);
  border-right-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 16px;
}
.app-footer {
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: #4e6578;
  margin-top: auto;
}
.file-input { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 390px) {
  .status-grid, .choice-row, .action-row, .video-action-row, .nav-row, .overlay-actions, .preset-grid {
    grid-template-columns: 1fr;
  }
  .app-shell { max-width: 100%; }
}
