:root {
  --bg: #0b0d12;
  --surface: #151821;
  --surface-2: #1d212c;
  --border: #2a2f3c;
  --text: #f2f4f8;
  --muted: #9aa3b5;
  --accent: #6d6af8;
  --accent-2: #8f8cff;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
body { font: 400 1rem/1.6 Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.err { color: var(--bad); font-size: .9rem; min-height: 1.4em; }
.err.big { font-size: 1rem; padding: 16px; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3); border-radius: 12px; }

.btn { min-height: 48px; padding: 12px 24px; border-radius: 12px; font-weight: 600; border: 0; transition: transform .15s, background .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); }
.text-btn { background: none; border: 0; color: var(--accent-2); font-weight: 600; min-height: 44px; padding: 0 4px; }
.text-btn.danger { color: var(--bad); }
.icon-btn { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: rgba(20,22,30,.55); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { background: var(--accent); border-color: var(--accent); }

/* Lock */
.lock { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.lock-card { width: 100%; max-width: 380px; text-align: center; }
.lock-card h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin: 16px 0 4px; }
.lock-card form { display: grid; gap: 12px; margin-top: 28px; }
.lock-card input { min-height: 52px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 1.05rem; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: url(icon.svg) center/cover; box-shadow: 0 12px 40px rgba(109,106,248,.35); }

/* Camera */
.cam { position: fixed; inset: 0; background: #000; overflow: hidden; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shade { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.frame { position: relative; width: 88%; height: 48%; max-width: 640px; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); transition: height .25s; }
.frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.frame i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.frame i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.frame i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.frame i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.frame.flash { animation: flash .35s ease; }
@keyframes flash { 0% { background: rgba(255,255,255,.6); } 100% { background: transparent; } }
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-top) + 12px) 16px 12px; }
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.hint { position: absolute; left: 0; right: 0; top: calc(26% - 44px); text-align: center; font-weight: 600; font-size: .95rem; text-shadow: 0 1px 8px rgba(0,0,0,.7); }
.nocam { position: absolute; inset: 30% 16px auto; padding: 20px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center; padding: 20px 16px calc(var(--safe-bottom) + 28px); }
.shutter { width: 80px; height: 80px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 5px; transition: transform .12s; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; }
.shutter:active { transform: scale(.92); }
.shutter:disabled { opacity: .4; }

/* Sheets */
.sheet { position: fixed; inset: 0; overflow-y: auto; background: var(--bg); padding: calc(var(--safe-top) + 8px) 16px calc(var(--safe-bottom) + 32px); animation: up .25s ease; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.sheet h2 { font-size: 1.4rem; font-weight: 800; margin: 12px auto 16px; }
.pill { font-size: .8rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill:empty { display: none; }
.shot { display: block; width: 100%; max-height: 180px; object-fit: contain; border-radius: 12px; background: var(--surface); margin: 8px auto 20px; }
.loading { text-align: center; padding: 32px 0; color: var(--muted); }
.spinner { width: 40px; height: 40px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { margin-bottom: 16px; }
#retryBtn, #deepBtn { display: block; width: 100%; margin-top: 16px; }

.answers { list-style: none; padding: 0; display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.q { color: var(--muted); font-size: .92rem; white-space: pre-wrap; }
.q b { color: var(--text); margin-right: 6px; }
.a-label { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.a { font-size: 1.2rem; font-weight: 700; line-height: 1.4; white-space: pre-wrap; }
.conf { font-size: .72rem; letter-spacing: .04em; padding: 3px 10px; border-radius: 999px; text-transform: none; font-weight: 600; }
.conf.high { color: var(--good); background: rgba(52,211,153,.12); }
.conf.medium { color: var(--warn); background: rgba(251,191,36,.12); }
.conf.low { color: var(--bad); background: rgba(248,113,113,.12); }
details { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
summary { cursor: pointer; color: var(--accent-2); font-weight: 600; font-size: .92rem; min-height: 32px; display: flex; align-items: center; }
details p { margin-top: 8px; white-space: pre-wrap; font-size: .95rem; }
.copy { background: none; border: 0; color: var(--muted); font-size: .75rem; font-weight: 600; padding: 4px 0; }

.hist { list-style: none; padding: 0; display: grid; gap: 10px; }
.hist button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.hist img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex: none; }
.hist span { display: block; overflow: hidden; }
.hist strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist small { color: var(--muted); }

dialog { margin: auto; width: calc(100% - 32px); max-width: 420px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { font-size: 1.15rem; margin-bottom: 6px; }
dialog p { font-size: .9rem; }
dialog textarea { width: 100%; margin: 14px 0; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); resize: vertical; }
dialog .row { display: flex; gap: 10px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
