/* SetuCare Passport Photo — mobile-first, light/dark */
:root {
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #f7f8fa; --border: #e3e6eb; --border-strong: #cfd4dc;
  --text: #0e1525; --muted: #5d6677; --faint: #8a93a3;
  --primary: #1c4fd8; --primary-ink: #ffffff; --primary-soft: #e8eefc;
  --ok: #10935a; --ok-soft: #e4f5ec; --warn: #b86e00; --warn-soft: #fdf1dc; --fail: #c8321f; --fail-soft: #fbe6e3;
  --stage: #141924; --stage-2: #1d2331; --stage-ink: #e9ecf2; --stage-muted: #98a1b3;
  --guide: #2f6bff;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 48px rgba(8, 12, 24, .35);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Bengali", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #121826; --surface-2: #171e2e; --border: #232b3c; --border-strong: #313b50;
    --text: #e8ebf2; --muted: #a1a9b8; --faint: #6f788a;
    --primary: #4c7dff; --primary-soft: #1a2546;
    --ok: #34c27e; --ok-soft: #0f2a1e; --warn: #f0a83a; --warn-soft: #2c210d; --fail: #ff6b57; --fail-soft: #33150f;
    --stage: #070a10; --stage-2: #0e131d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --surface: #121826; --surface-2: #171e2e; --border: #232b3c; --border-strong: #313b50;
  --text: #e8ebf2; --muted: #a1a9b8; --faint: #6f788a;
  --primary: #4c7dff; --primary-soft: #1a2546;
  --ok: #34c27e; --ok-soft: #0f2a1e; --warn: #f0a83a; --warn-soft: #2c210d; --fail: #ff6b57; --fail-soft: #33150f;
  --stage: #070a10; --stage-2: #0e131d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, select, input { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; letter-spacing: -.01em; font-size: 17px; white-space: nowrap; }
.brand-by { color: var(--faint); font-size: 13px; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.privacy-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ok); background: var(--ok-soft); padding: 5px 10px; border-radius: 999px; font-weight: 600; }
.privacy-pill svg { width: 14px; height: 14px; }
@media (max-width: 520px) { .brand-by, .privacy-pill { display: none; } }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.icon-btn:hover { border-color: var(--border-strong); }

/* Layout */
.app { display: grid; gap: 14px; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto;
  grid-template-areas: "country" "stage" "panel"; }
.country { grid-area: country; } .stage { grid-area: stage; } .panel { grid-area: panel; }
@media (min-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "stage country" "stage panel"; grid-template-rows: auto 1fr; padding-top: 22px; gap: 18px 22px; }
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h2 { font-size: 15px; margin: 0 0 10px; letter-spacing: -.005em; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { margin: 0; }
.eyebrow { display: block; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.muted { color: var(--faint); font-weight: 400; }
.fine { font-size: 12.5px; color: var(--faint); margin: 8px 0 0; }

/* Country */
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select { width: 100%; appearance: none; -webkit-appearance: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 38px 12px 14px; font-size: 16px; font-weight: 600; cursor: pointer; }
select:focus-visible, input:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.spec-line { margin: 10px 0 0; color: var(--muted); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.spec-line b { color: var(--text); font-weight: 600; }
.spec-line a { color: var(--primary); text-decoration: none; }
.spec-line .bg-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--border-strong); vertical-align: -1px; margin-right: 4px; }

/* Stage */
.stage { position: relative; background: radial-gradient(120% 90% at 50% 0%, var(--stage-2), var(--stage)); border-radius: 22px; padding: 22px 16px 18px; color: var(--stage-ink);
  display: flex; flex-direction: column; align-items: center; min-height: 420px; overflow: hidden; }
@media (min-width: 960px) { .stage { position: sticky; top: 78px; align-self: start; height: calc(100dvh - 100px); min-height: 560px; justify-content: center; padding: 28px; } }
@media (max-width: 959px) { [data-state="result"] .stage, [data-state="processing"] .stage { min-height: 0; } .panel { display: flex; flex-direction: column; } [data-state="result"] .panel .export { order: -1; margin: 0 0 12px; } .panel .card + .card { margin-top: 0; } .panel .card { margin-bottom: 12px; } }

.frame-wrap { --fh: min(58dvh, 560px); display: grid; grid-template-columns: auto auto; grid-template-areas: "f y" "x ."; gap: 8px; align-items: center; justify-items: center; }
@media (min-width: 960px) { .frame-wrap { --fh: min(68dvh, 640px); } }
.frame { grid-area: f; position: relative; width: min(calc(100vw - 92px), calc(var(--fh) * var(--ar, .7778))); aspect-ratio: var(--ar, .7778);
  background: #fff; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,.06), var(--shadow-lg); transition: aspect-ratio .25s ease, width .25s ease; }
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.frame.mirror #live { transform: scaleX(-1); }
.guides { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity .2s; }
.guides .oval { fill: none; stroke: var(--guide); stroke-width: 2.2; stroke-dasharray: 7 6; vector-effect: non-scaling-stroke; opacity: .85; }
.guides .band { fill: var(--guide); opacity: .08; }
.guides .line { stroke: var(--guide); stroke-width: 1.4; vector-effect: non-scaling-stroke; opacity: .7; stroke-dasharray: 3 4; }
.guides text { fill: var(--guide); font: 600 15px var(--font); opacity: .9; }
[data-state="result"] .guides, .guides.off { opacity: 0; }

.ruler { color: var(--stage-muted); font-size: 12px; font-variant-numeric: tabular-nums; position: relative; }
.ruler-x { grid-area: x; width: 100%; text-align: center; border-top: 1px solid rgba(255,255,255,.18); padding-top: 4px; }
.ruler-y { grid-area: y; height: 100%; writing-mode: vertical-rl; text-align: center; border-left: 1px solid rgba(255,255,255,.18); padding-left: 4px; display: flex; justify-content: center; }
[data-state="idle"] .frame-wrap { display: none; }

.empty { display: none; text-align: center; max-width: 420px; margin: auto; padding: 24px 8px; }
[data-state="idle"] .empty { display: block; }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); }
.empty-icon svg { width: 36px; height: 36px; }
.empty h1 { font-size: clamp(24px, 4.6vw, 32px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.empty p { color: var(--stage-muted); margin: 0 0 22px; }
.empty-actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 480px) { .empty-actions { flex-direction: row; justify-content: center; } }
.empty .btn-ghost { background: rgba(255,255,255,.06); color: var(--stage-ink); border-color: rgba(255,255,255,.16); }
.empty .fine { color: var(--stage-muted); margin-top: 14px; }

.busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(255,255,255,.82); color: #1d2433; font-weight: 600; font-size: 14px; backdrop-filter: blur(2px); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #d7dce5; border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: #fff; text-shadow: 0 4px 30px rgba(0,0,0,.45); pointer-events: none; }
.countdown:empty { display: none; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .95 } 100% { opacity: 0 } }

/* Live status chips */
.chips { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 30px; max-width: 560px; }
.chips li { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 5px 10px 5px 7px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--stage-ink); }
.chips li svg { width: 15px; height: 15px; }
.chips li.ok svg { color: #43d38e; } .chips li.warn { background: rgba(240,168,58,.16); color: #ffd28a; } .chips li.fail { background: rgba(255,107,87,.18); color: #ffb2a6; }
[data-state="idle"] .chips, [data-state="result"] .chips { display: none; }

/* Shutter row */
.controls { display: flex; align-items: center; justify-content: center; gap: 34px; margin-top: 14px; }
[data-state="idle"] .controls, [data-state="result"] .controls { display: none; }
.round-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); color: var(--stage-ink); cursor: pointer; }
.round-btn:hover { background: rgba(255,255,255,.16); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid rgba(255,255,255,.9); background: transparent; padding: 5px; cursor: pointer; transition: border-color .2s, transform .1s; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: background .2s, transform .15s; }
.shutter:active span { transform: scale(.92); }
.shutter.ready { border-color: #43d38e; box-shadow: 0 0 0 6px rgba(67,211,142,.18); }
.shutter:disabled { opacity: .45; cursor: default; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn-lg { height: 52px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--primary); padding: 0; cursor: pointer; font-weight: 600; font-size: 13.5px; }

/* Panel */
.result-only { display: none; }
[data-state="result"] .result-only { display: block; }
[data-state="result"] .pre-only { display: none; }
.hint { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.score { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.score.ok { background: var(--ok-soft); color: var(--ok); } .score.warn { background: var(--warn-soft); color: var(--warn); } .score.fail { background: var(--fail-soft); color: var(--fail); }
.checks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.checks li i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.checks li i svg { width: 14px; height: 14px; }
.checks .ok i { background: var(--ok-soft); color: var(--ok); }
.checks .warn i { background: var(--warn-soft); color: var(--warn); }
.checks .fail i { background: var(--fail-soft); color: var(--fail); }
.checks .ok { color: var(--muted); }
.passed { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.passed summary { cursor: pointer; font-weight: 600; color: var(--ok); }
.passed .checks { margin-top: 10px; }

.adjust summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 650; list-style: none; }
.adjust summary::-webkit-details-marker { display: none; }
.adjust summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.adjust[open] summary::after { transform: rotate(225deg); }
.sliders { display: grid; gap: 12px; margin-top: 14px; }
.sliders label { display: grid; grid-template-columns: 96px 1fr; align-items: center; font-size: 13.5px; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.bg-row { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-strong); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { outline: 3px solid var(--primary); outline-offset: 2px; }
.swatch .tag { position: absolute; top: -8px; right: -10px; font-size: 9.5px; font-weight: 700; background: var(--primary); color: #fff; border-radius: 6px; padding: 1px 4px; }

.seg-group { display: grid; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 9px; height: 38px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.out + .out { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.out-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 6px 0 10px; }
.out-title { font-weight: 700; font-size: 15px; }
.out-line { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sheet-preview { display: block; width: 100%; height: auto; margin: 0 0 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow); }
.sheet-preview.portrait { width: auto; max-width: 100%; max-height: 360px; margin-inline: auto; }
.out-sheet .export-actions .btn-ghost:first-child { flex-basis: 100%; }
.out-sheet .fine { margin: 8px 0 0; }
.mail-what { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.export-actions .btn { flex: 1 1 130px; }
.export-actions .btn-primary { flex-basis: 100%; height: 50px; font-size: 16px; }
.export #btnRetake { width: 100%; margin-top: 8px; }
.share-site { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; }
.share-site .fine { margin: 2px 0 0; }
.btn-fb { background: #1877f2; color: #fff; flex: 0 0 auto; }
.btn-fb:hover { background: #166fe5; }
.btn-fb svg { width: 20px; height: 20px; }
@media (max-width: 520px) { .btn-fb { flex: 1 1 100%; } }
.disclaimer { font-size: 12px; color: var(--faint); margin: 12px 4px 0; }

/* Dialogs (bottom sheet on mobile, modal on desktop) */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--text); width: min(520px, 100vw); max-height: 92dvh; border-radius: 20px 20px 0 0; margin: auto auto 0; box-shadow: var(--shadow-lg); }
@media (min-width: 640px) { dialog.sheet { border-radius: 20px; margin: auto; } }
dialog.sheet::backdrop { background: rgba(6, 10, 18, .55); backdrop-filter: blur(2px); }
dialog[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }
.sheet-body { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 14px; overflow: auto; max-height: 92dvh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field select, .field input { font-size: 16px; font-weight: 500; color: var(--text); }
.field input { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; width: 100%; }
.toggles { display: grid; gap: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 9px 0; cursor: pointer; font-size: 14.5px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 42px; height: 25px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { transform: translateX(17px); }
.hw { display: grid; gap: 12px; }
.hw:not(:empty) { padding-top: 12px; border-top: 1px solid var(--border); }
.hw label { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.hw output { font-variant-numeric: tabular-nums; text-align: right; font-size: 12.5px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-err { color: var(--fail); font-size: 13.5px; margin: 0; min-height: 1em; }

/* Drop + toast */
.drop { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(28, 79, 216, .18); backdrop-filter: blur(3px); }
.drop div { display: flex; align-items: center; gap: 10px; padding: 18px 26px; border-radius: 16px; background: var(--surface); border: 2px dashed var(--primary); font-weight: 700; font-size: 17px; }
.drop.on { display: grid; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 60; background: #121826; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #8f1d10; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
[data-state="processing"] .chips, [data-state="processing"] .controls { display: none; }
.checks li.passed-wrap { display: block; }
