:root {
  --paper: #f3f1ec; --ink: #0e0e0e; --mute: #64615b; --line: #d6d2c8; --white: #fff;
  --teal: #00a19a; --pink: #e5197c; --orange: #f39200; --silver: #b9c2c8; --bad: #b3261e;
  --display: "Clash Display", "General Sans", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.4 "General Sans", system-ui, sans-serif; padding-bottom: calc(24px + env(safe-area-inset-bottom)); overflow-x: hidden; }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .07; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* hero: the number is the moment */
.hero { position: relative; padding: calc(14px + env(safe-area-inset-top)) 16px 18px; border-bottom: 3px solid var(--ink); overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; bottom: -6px; width: 220px; height: 14px; background: linear-gradient(90deg, var(--teal) 0 33%, var(--pink) 33% 66%, var(--orange) 66%); transform: skewX(-30deg); }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.mark { font: 700 20px/1 var(--display); letter-spacing: .02em; }
.mark em { font-style: normal; color: var(--teal); margin-left: 2px; }
.csv { font-weight: 600; color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--pink); padding-bottom: 1px; }
.worth { margin: 22px 0 10px; }
.worth-num { display: block; font: 700 clamp(64px, 21vw, 150px)/.86 var(--display); letter-spacing: -.035em; transform-origin: left bottom; }
.worth-sub { display: block; color: var(--mute); margin-top: 8px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; color: var(--mute); }
.stats b { color: var(--ink); font: 700 19px/1 var(--display); margin-right: 3px; }

main { position: relative; z-index: 2; max-width: 900px; margin: 0 auto; padding: 18px 16px 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0 0 8px; letter-spacing: -.01em; }
.block { background: var(--white); border: 2px solid var(--ink); padding: 18px; margin-bottom: 16px; }

/* scan entry */
.entry { margin-bottom: 18px; }
.boxrow { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 10px; }
.boxrow label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.boxrow input { width: 88px; font: 700 20px/1 var(--display); padding: 8px 10px; border: 2px solid var(--ink); background: var(--white); }
.next { color: var(--mute); }
.next b { color: var(--ink); font: 700 22px/1 var(--display); }
.shutter-cta { position: relative; display: block; width: 100%; text-align: left; border: 0; background: var(--ink); color: var(--white); padding: 24px 20px 22px; overflow: hidden; }
.shutter-cta::before { content: ""; position: absolute; right: 18px; top: 50%; width: 58px; height: 58px; margin-top: -29px; border-radius: 50%; border: 4px solid var(--white); box-shadow: inset 0 0 0 5px var(--ink), inset 0 0 0 30px var(--teal); }
.cta-big { display: block; font: 700 40px/1 var(--display); letter-spacing: -.02em; margin-bottom: 8px; }
.cta-sub { display: block; color: #cfcac0; max-width: 72%; font-size: 15px; }
.shutter-cta:active { transform: translateY(1px); }
.filepick { display: block; margin-top: 10px; color: var(--mute); text-decoration: underline; font-size: 15px; cursor: pointer; }
.filepick input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* batch tray */
.tray-wrap { margin-bottom: 18px; }
.tray-head { font-size: 15px; color: var(--mute); margin-bottom: 8px; }
.tray-head b { color: var(--ink); font: 700 20px/1 var(--display); }
.tray { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.chip { position: relative; flex: 0 0 78px; scroll-snap-align: start; border: 2px solid var(--line); background: var(--white); padding: 0; text-align: left; }
.chip img { display: block; width: 100%; aspect-ratio: 5/7; object-fit: cover; }
.chip-no { position: absolute; top: 3px; left: 3px; background: var(--ink); color: var(--white); font: 600 11px/1 "General Sans"; padding: 3px 4px; }
.chip-cap { display: block; font-size: 12px; font-weight: 600; padding: 4px 5px; }
.chip.read { border-color: var(--teal); }
.chip.read img { animation: pulse 1s ease-in-out infinite alternate; }
.chip.wait img { opacity: .55; }
.chip.done { border-color: var(--ink); }
.chip.fail, .chip.cap { border-color: var(--bad); }
.chip.fail .chip-cap, .chip.cap .chip-cap { color: var(--bad); }
@keyframes pulse { to { filter: brightness(1.25) saturate(1.3); } }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border: 2px solid var(--ink); margin: 6px 0 8px; position: sticky; top: env(safe-area-inset-top); z-index: 4; background: var(--paper); }
.tabs button { border: 0; background: none; padding: 12px 2px; font-size: 15px; font-weight: 600; border-right: 2px solid var(--ink); }
.tabs button:last-child { border-right: 0; }
.tabs button.on { background: var(--ink); color: var(--white); }
.view-note { color: var(--mute); font-size: 15px; margin: 0 0 12px; }

/* tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.tile { position: relative; display: flex; flex-direction: column; text-align: left; background: var(--white); border: 2px solid var(--ink); padding: 0 0 10px; }
.tile img { width: 100%; aspect-ratio: 5/7; object-fit: cover; background: #e6e2da; display: block; margin-bottom: 8px; border-bottom: 2px solid var(--ink); }
.tile img.noimg { visibility: hidden; }
.tile .pos { position: absolute; top: 6px; left: 6px; background: var(--ink); color: var(--white); font: 600 12px/1 "General Sans"; padding: 4px 6px; }
.tile .run { position: absolute; top: 6px; right: 6px; background: var(--white); color: var(--ink); font: 700 14px/1 var(--display); padding: 4px 6px; border: 2px solid var(--ink); }
.tile .run.low { background: var(--orange); }
.tile .run.one { background: var(--pink); color: var(--white); border-color: var(--pink); }
.tile.flag { border-color: var(--orange); }
.tile.flag::after { content: "check"; position: absolute; left: 6px; top: 30px; background: var(--orange); font: 600 11px/1 "General Sans"; padding: 3px 5px; }
.tile .t { padding: 0 10px; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .v { padding: 6px 10px 0; font: 700 22px/1 var(--display); }
.tile.sk { height: 270px; border-color: var(--line); background: linear-gradient(90deg, #e9e5dd, #f7f5f0, #e9e5dd); background-size: 200% 100%; animation: sh 1.2s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }
.empty p { margin: 0; }
.err-line { color: var(--bad); }
.link { background: none; border: 0; color: var(--teal); text-decoration: underline; padding: 0; }

/* sets */
.set { margin-bottom: 28px; }
.set-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 3px solid var(--ink); padding-bottom: 6px; margin-bottom: 8px; }
.set-h h3 { font-size: 24px; margin: 0; }
.set-h span { color: var(--mute); font-size: 15px; white-space: nowrap; }
.pars { font-size: 14px; color: var(--mute); margin-bottom: 10px; }
.par + .par::before { content: " · "; color: var(--silver); }

/* camera */
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: var(--white); }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame { position: absolute; left: 50%; top: 46%; width: min(72vw, 52svh); aspect-ratio: 5/7; transform: translate(-50%, -50%); }
.frame i { position: absolute; width: 34px; height: 34px; border: 4px solid var(--white); }
.frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.cam-slot { font-size: 16px; } .cam-slot b { font: 700 20px/1 var(--display); }
.cam-back { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.cam-back input { width: 22px; height: 22px; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: calc(132px + env(safe-area-inset-bottom)); text-align: center; font: 600 18px/1 var(--display); text-shadow: 0 1px 4px #000; margin: 0; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.cam-btn { justify-self: start; background: var(--white); color: var(--ink); border: 0; padding: 12px 18px; font-weight: 700; }
.cam-n { justify-self: end; font-size: 15px; } .cam-n b { font: 700 24px/1 var(--display); }
.shoot { width: 82px; height: 82px; border-radius: 50%; border: 5px solid var(--white); background: none; padding: 5px; }
.shoot span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--white); transition: transform .08s; }
.shoot:active span { transform: scale(.86); background: var(--teal); }
.flash { position: absolute; inset: 0; background: var(--white); opacity: 0; pointer-events: none; }
.flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }

/* card sheet (full screen, not draggable) */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-in { max-width: 640px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px calc(30px + env(safe-area-inset-bottom)); perspective: 900px; }
.slab { position: relative; width: min(62vw, 260px); margin: 0 auto 18px; padding: 10px 10px 34px; background: linear-gradient(160deg, #fdfdfd, #dfe4e7); border: 2px solid var(--ink); }
.slab img { display: block; width: 100%; aspect-ratio: 5/7; object-fit: cover; background: #ddd; }
.slab-tag { position: absolute; left: 10px; right: 10px; bottom: 8px; font: 600 13px/1.2 "General Sans"; text-align: center; }
form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form .wide { grid-column: 1 / -1; }
form label { display: flex; flex-direction: column; font-size: 14px; color: var(--mute); gap: 4px; }
input, textarea, select { font: inherit; font-size: 17px; color: var(--ink); background: var(--white); border: 2px solid #bdb8ad; padding: 10px; width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--teal); }
.flags { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.ck { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink) !important; font-size: 17px !important; }
.ck input { width: 22px; height: 22px; }
.est { margin: 0; font-size: 14px; color: var(--mute); }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.links a { color: var(--ink); font-weight: 600; border-bottom: 3px solid var(--teal); text-decoration: none; padding: 4px 0; }
.ferr { color: var(--bad); margin: 0; }
.go { display: block; width: 100%; background: var(--ink); color: var(--white); border: 0; padding: 16px; font-weight: 600; font-size: 18px; min-height: 54px; }
.go:disabled { opacity: .55; }
.plain { display: block; width: 100%; background: none; border: 0; color: var(--mute); padding: 12px; text-decoration: underline; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; background: var(--ink); color: var(--white); padding: 14px 16px; font-weight: 500; border-left: 6px solid var(--pink); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* checklist */
.cl-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.cl-top b { font: 700 40px/1 var(--display); }
.cl-bar { height: 10px; border: 2px solid var(--ink); margin-bottom: 18px; background: var(--white); }
.cl-bar i { display: block; height: 100%; background: var(--teal); }
.cl-set { margin-bottom: 20px; }
.cl-set h3 { font-size: 20px; border-bottom: 3px solid var(--ink); padding-bottom: 4px; margin-bottom: 0; }
.cl-row { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cl-row .no { font: 700 18px/1 var(--display); }
.cl-row .nm small { display: block; color: var(--mute); font-size: 13px; }
.cl-row .have { font-weight: 700; color: var(--teal); }
.cl-row a { color: var(--ink); font-weight: 600; font-size: 14px; border-bottom: 2px solid var(--pink); text-decoration: none; }
.cl-row.got .no { color: var(--teal); }
.cl-row .star { color: var(--orange); }
