:root {
  --bg: #FBFAF7;
  --navy: #1B2A4A;
  --navy-soft: #E8ECF4;
  --accent-soft: #FDE6DF;
  --card: #FFFFFF;
  --ink: #17181C;
  --muted: #6B6E76;
  --line: #E7E4DE;
  --accent: #F2542D;
  --accent-ink: #FFFFFF;
  --ok: #1F9D6B;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; overflow: auto; }
.screen.dark { background: #000; color: #fff; overflow: hidden; }

/* shared brand lockup */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.big { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; border-radius: 16px; font-weight: 600; font-size: 17px; }
.primary { background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 12px 18px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.primary:active { filter: brightness(.92); }
.secondary { background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.link { color: var(--accent); font-weight: 600; }

/* camera */
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { object-fit: cover; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s ease-out; }
#flash.on { opacity: .85; transition: none; }
.cam-top { position: absolute; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round { width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.45); display: grid; place-items: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.round.on { background: #fff; color: #000; }
.seg { display: flex; background: rgba(0,0,0,.45); border-radius: 99px; padding: 3px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.seg button { padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,.8); }
.seg button.on { background: #fff; color: #000; }
.hint { position: absolute; left: 50%; top: calc(72px + var(--safe-t)); transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 99px; font-size: 15px; font-weight: 500; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .2s; }
.hint.good { background: var(--accent); }
#debug { position: absolute; left: 8px; top: calc(120px + var(--safe-t)); margin: 0; font: 11px/1.3 ui-monospace, monospace; background: rgba(0,0,0,.6); padding: 6px 8px; border-radius: 6px; pointer-events: none; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 24px calc(22px + var(--safe-b)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.shutter span { width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.88); }
.tray { justify-self: start; width: 52px; height: 52px; border-radius: 10px; background: rgba(255,255,255,.12); position: relative; overflow: visible; }
.tray img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 2px solid #fff; display: none; }
.tray.has img { display: block; }
.tray span { position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--accent); font-size: 12px; font-weight: 700; display: none; place-items: center; }
.tray.has span { display: grid; }
.tray.pop { animation: pop .35s ease-out; }
@keyframes pop { 40% { transform: scale(1.18); } }
.done { justify-self: end; font-weight: 700; font-size: 17px; padding: 10px 6px; }

/* review */
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; background: rgba(246,245,242,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar h2 { font-size: 18px; margin: 0; flex: 1; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; }
.chip-btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.chip-btn svg { width: 18px; height: 18px; }
.pages { padding: 16px 16px 120px; display: grid; gap: 16px; max-width: 640px; margin: 0 auto; }
.page { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.page .img { background: #EDEBE6; display: grid; place-items: center; padding: 12px; }
.page img { max-width: 100%; max-height: 62vh; display: block; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.page .row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.page .num { font-weight: 700; color: var(--muted); font-size: 13px; margin-right: 4px; }
.filters { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 99px; }
.filters button { padding: 6px 11px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); }
.filters button.on { background: var(--ink); color: #fff; }
.page .tools { margin-left: auto; display: flex; gap: 2px; }
.page .tools button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.page .tools svg { width: 20px; height: 20px; }
.page.busy img { opacity: .45; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.rev-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; justify-content: space-between; padding: 12px 16px calc(12px + var(--safe-b)); background: rgba(246,245,242,.95); border-top: 1px solid var(--line); }
.rev-actions .primary { flex: 1; max-width: 320px; margin-left: auto; min-height: 50px; }
.ghost { color: var(--muted); font-weight: 600; padding: 0 8px; }

/* crop */
.crop-stage { position: absolute; inset: 0 0 calc(76px + var(--safe-b)); touch-action: none; }
#crop-canvas { width: 100%; height: 100%; display: block; }
#loupe { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 12px rgba(0,0,0,.5); pointer-events: none; display: none; }
.crop-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 12px 12px calc(12px + var(--safe-b)); background: #111; }
.crop-bar .primary { margin-left: auto; }
.ghost-dark { color: #ddd; font-weight: 600; padding: 10px 8px; white-space: nowrap; border-radius: 10px; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 10; max-width: calc(100% - 32px); text-align: center; }

.sample-btn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(126px + var(--safe-b)); background: rgba(255,255,255,.92); color: #000; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 99px; }
.sample-btn.rec { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ snpr app */
.center { display: grid; place-content: center; justify-items: center; text-align: center; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 700; font-size: 17px; }
.err { color: #B42318; font-size: 14.5px; margin: 0; }
.link { color: var(--accent); font-weight: 600; padding: 6px 0; }
.link.muted { color: var(--muted); font-weight: 500; }
.word { font: 800 26px/1 "Inter Tight", Inter, -apple-system, system-ui, sans-serif; letter-spacing: -0.045em; }
.brand.small .word { font-size: 23px; }
.brand.small { margin: 0; gap: 8px; }

/* sign in */
#auth { padding: calc(40px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.auth-card { max-width: 400px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.auth-card .brand { margin-bottom: 20px; }
.auth-card h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.auth-card p { margin: 0 0 8px; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
#auth-form input { font: inherit; font-size: 17px; color: var(--ink); padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
#auth-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
button:disabled { opacity: .55; }

/* home */
#home { padding-bottom: calc(110px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(251,250,247,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.home-body { max-width: 680px; margin: 0 auto; padding: 4px 16px 20px; }
.ask { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 6px 6px 6px 14px; box-shadow: 0 2px 10px rgba(20,20,30,.04); }
.ask:focus-within { border-color: var(--accent); }
.ask > svg { color: var(--muted); width: 20px; height: 20px; }
.ask input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 17px; padding: 10px 0; color: var(--ink); }
.ask input:focus { outline: none; }
.ask .send { width: 42px; height: 42px; border-radius: 13px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.answer { position: relative; margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 16px 14px; }
.a-q { color: var(--muted); font-size: 14px; margin-right: 28px; }
.a-head { font: 800 26px/1.15 "Inter Tight", Inter, -apple-system, system-ui, sans-serif; letter-spacing: -0.02em; margin: 6px 0 4px; }
.a-text { margin: 6px 0 0; line-height: 1.5; }
.a-wait { color: var(--muted); padding: 10px 0 4px; display: flex; align-items: center; gap: 10px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.a-src { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; min-width: 0; max-width: 100%; }
.src { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 6px 6px; flex: none; max-width: 270px; }
.src img { width: 36px; height: 48px; object-fit: cover; border-radius: 4px; background: #EDEBE6; }
.src span { display: flex; flex-direction: column; min-width: 0; }
.src b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src small { color: var(--muted); font-size: 12.5px; }
.a-close { position: absolute; right: 8px; top: 6px; width: 32px; height: 32px; font-size: 22px; color: var(--muted); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.list-head h2 { font-size: 17px; margin: 0; }
.list-head input { font: inherit; font-size: 15px; width: 130px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); color: var(--ink); }
.docs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }   /* minmax: long titles must ellipsize, not widen the page */
.doc-row { min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px 8px; width: 100%; }
.doc-row:disabled { opacity: 1; }
.thumb { width: 44px; height: 58px; border-radius: 6px; background: #EDEBE6; overflow: hidden; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.thumb img.in { opacity: 1; }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; flex: none; }
.chip.busy { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.bad { color: #B42318; background: #FEE4E2; border-color: transparent; }
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state h3 { margin: 12px 0 4px; }
.empty-state p { margin: 0 auto; max-width: 300px; }
.fab-row { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px 16px calc(16px + var(--safe-b)); background: linear-gradient(rgba(251,250,247,0), rgba(251,250,247,.96) 40%); pointer-events: none; }
.fab-row > * { pointer-events: auto; }
.fab { display: inline-flex; align-items: center; gap: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 18px; padding: 16px 30px; border-radius: 99px; box-shadow: 0 10px 24px -8px rgba(242,84,45,.6); }
.fab-side { width: 52px; height: 52px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink); cursor: pointer; }
.draft-btn span { background: var(--accent); color: #fff; min-width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; font-weight: 800; font-size: 14px; padding: 0 6px; }

/* one document */
.doc-body { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(40px + var(--safe-b)); }
.doc-pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.pg { flex: none; background: #EDEBE6; border-radius: 10px; padding: 8px; }
.pg img { display: block; max-height: 44vh; max-width: 78vw; min-width: 120px; min-height: 160px; box-shadow: 0 1px 4px rgba(0,0,0,.12); background: #fff; }
.doc-h { font: 800 26px/1.15 "Inter Tight", Inter, -apple-system, system-ui, sans-serif; letter-spacing: -0.02em; margin: 16px 0 8px; }
.doc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-chips span, .tags span { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; font-size: 14px; font-weight: 600; }
.doc-sum { line-height: 1.55; margin: 14px 0; }
.sec { font-size: 15px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.facts { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; }
.f-subj { font-weight: 700; margin-bottom: 4px; }
.f-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr; gap: 2px 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.f-row:first-of-type { border-top: 0; }
.f-row span { color: var(--muted); text-transform: capitalize; }
.f-row b { font-weight: 600; word-break: break-word; }
.f-row small { grid-column: 2; color: var(--muted); font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.tags span { font-weight: 500; color: var(--muted); }
.fulltext { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 14px 0; }
.fulltext summary { font-weight: 600; cursor: pointer; }
.fulltext pre { white-space: pre-wrap; font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 10px 0 0; }
.proof { display: flex; gap: 8px; align-items: center; color: var(--navy); background: var(--navy-soft); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin: 16px 0 12px; }
.proof svg { width: 18px; height: 18px; }
.doc-body > .secondary { width: 100%; padding: 13px; border-radius: 12px; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.card.warn { border-color: #FECDCA; background: #FFFBFA; margin: 14px 0; }
.card.warn p { margin: 4px 0 10px; }

/* account */
.set-body { max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.set-body > .secondary { padding: 13px; border-radius: 12px; font-weight: 600; }
.protect { background: var(--navy); color: #fff; border: 0; }
.protect .p-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.protect .p-head svg { width: 20px; height: 20px; }
.protect p { opacity: .85; margin: 8px 0 12px; line-height: 1.5; }
.navy { background: #fff; color: var(--navy); font-weight: 700; border-radius: 12px; padding: 12px 16px; width: 100%; }
.danger-link { color: #B42318; font-weight: 600; padding: 12px; }
.trouble { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; padding: 4px 4px 20px; }
.rev-actions .ghost { padding: 0 6px; }

/* billing */
.trial-banner { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); color: #9A3412; font-size: 14.5px; font-weight: 600; text-align: left; }
.trial-banner b { color: var(--accent); white-space: nowrap; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.plan-actions button { flex: 1; min-width: 130px; padding: 11px 12px; border-radius: 12px; font-weight: 700; }
.plan-actions .primary { display: inline-flex; }
.plan-actions .secondary { border: 1px solid var(--line); }
.usage { display: grid; gap: 8px; margin-top: 14px; }
.meter { font-size: 13.5px; color: var(--muted); }
.meter .bar { height: 6px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; }
.meter .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
#paywall { padding: calc(36px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.pay-body { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.pay-body .brand { margin-bottom: 10px; }
.pay-body h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; line-height: 1.15; }
.pay-body > p { margin: 0 0 6px; line-height: 1.5; }
.prices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.price { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.price b { font: 800 30px/1 "Inter Tight", Inter, -apple-system, system-ui, sans-serif; letter-spacing: -0.02em; }
.price span { color: var(--muted); font-size: 14px; }
.price.best { border-color: var(--accent); }
.price em { position: absolute; top: -10px; background: var(--accent); color: #fff; font-style: normal; font-size: 11.5px; font-weight: 800; border-radius: 99px; padding: 2px 9px; }
.pay-links { display: flex; justify-content: space-between; align-items: center; }
