:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --navy: #0b2a5b;
    --blue: #154a90;
    --red: #e31f2b;
    --paper: #ffffff;
    --ink: #152033;
    --muted: #687386;
    --line: #e4e9f1;
    --bg: #f4f7fb;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
button { font: inherit; }
.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 18px 14px 32px; }
.camera-card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: 0 16px 40px rgba(27, 46, 78, .10); }
.brand-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
h1 { font-size: clamp(21px, 4vw, 30px); line-height: 1.15; margin: 0 0 4px; color: var(--navy); }
.brand-row p, .footnote { margin: 0; color: var(--muted); }
.privacy-chip { white-space: nowrap; font-size: 12px; font-weight: 700; color: #17663a; background: #e9f7ef; padding: 7px 10px; border-radius: 999px; }
.stage { position: relative; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 18px; background: #0e1420; isolation: isolate; }
#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); z-index: 1; }
.frame-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 2; pointer-events: none; }
.camera-message { position: absolute; z-index: 3; inset: 0; display: grid; place-content: center; gap: 7px; text-align: center; padding: 24px; color: #fff; background: rgba(9, 20, 38, .60); }
.camera-message span { font-size: 14px; opacity: .88; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; min-height: 48px; border: 0; border-radius: 13px; font-weight: 800; cursor: pointer; transition: transform .12s ease, opacity .12s ease; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--red), #be1522); }
.btn-secondary { color: var(--navy); background: #edf3fb; }
.preview-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.preview-section h2 { margin: 0 0 10px; font-size: 19px; }
.preview-image { display: block; width: min(100%, 520px); margin: 0 auto; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.footnote { margin-top: 15px; font-size: 12px; line-height: 1.55; }
@media (max-width: 580px) {
    .app-shell { padding: 0; }
    .camera-card { border-radius: 0; border-left: 0; border-right: 0; padding: 12px; box-shadow: none; }
    .brand-row { display: block; }
    .privacy-chip { display: inline-block; margin-top: 8px; }
    .stage { border-radius: 14px; }
}

/* v2: separate capture and preview screens */
.capture-shell { width: min(100%, 680px); }
.capture-card { padding: 12px; }
.capture-actions { margin-bottom: 0; }
.preview-shell { width: min(100%, 660px); }
.preview-card { padding: 18px; }
.preview-heading { text-align: center; margin-bottom: 16px; }
.preview-heading h1 { margin-bottom: 6px; }
.preview-heading p { margin: 0; color: var(--muted); }
.preview-page .preview-image { width: 100%; max-width: 560px; }
.preview-actions { max-width: 560px; margin: 14px auto 0; }
.status-text { min-height: 20px; margin: 10px auto 0; max-width: 560px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-state { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--navy); font-size: 20px; }
.btn-link { display: inline-grid; place-items: center; text-decoration: none; padding: 0 18px; margin-top: 8px; }
@media (max-width: 580px) {
    .capture-card, .preview-card { padding: 10px; }
    .capture-page .app-shell, .preview-page .app-shell { padding: 0; }
    .capture-page .stage { border-radius: 0; }
    .preview-heading { padding: 8px 6px 0; }
    .preview-actions { flex-direction: column; }
}

/* v4 fixes */
[hidden] { display: none !important; }
.preview-brand { display:flex; align-items:center; justify-content:center; gap:14px; padding:4px 8px 18px; text-align:left; }
.preview-brand img { width:76px; height:76px; object-fit:cover; border-radius:50%; border:1px solid var(--line); background:#fff; }
.preview-brand h1 { margin:0 0 4px; }
.preview-brand p { margin:0; color:var(--muted); }
.preview-state { min-height:280px; display:grid; place-items:center; align-content:center; gap:12px; text-align:center; color:var(--muted); padding:28px 16px; }
.preview-state strong { color:var(--navy); font-size:20px; }
.loader { width:36px; height:36px; border:4px solid #dfe7f2; border-top-color:var(--navy); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
@media (max-width:580px) {
  .preview-brand { justify-content:flex-start; padding:8px 6px 14px; }
  .preview-brand img { width:58px; height:58px; }
  .preview-brand h1 { font-size:22px; }
  .preview-brand p { font-size:13px; }
}
