:root {
  color-scheme: dark;
  --bg: #0d0b12; --surface: #17141f; --raised: #211c2c; --line: #2e2839;
  --text: #ece8f4; --muted: #a79fb8; --accent: #ff5c8a; --accent-2: #ff8fb0; --blue: #5b9cff; --gold: #ffd166; --error: #ff7a7a;
  --radius: 14px;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
main { max-width: 34rem; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
main.wide { max-width: 68rem; }
h1 { font-size: 1.05rem; margin: 0; letter-spacing: .02em; }
h2 { font-size: 1.25rem; margin: .2rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; color: var(--muted); font-weight: 600; }
p { margin: .4rem 0; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--error); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.screen { animation: fade .18s ease-out; }
.center { text-align: center; display: grid; justify-items: center; gap: 6px; padding-top: 10vh; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

button { font: inherit; color: inherit; border: 0; border-radius: 12px; padding: .7rem 1.1rem; cursor: pointer; background: var(--raised); touch-action: manipulation; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.primary { background: var(--accent); color: #1a0710; font-weight: 650; }
.ghost { background: transparent; border: 1px solid var(--line); }
.link { background: none; padding: .3rem 0; color: var(--muted); text-decoration: underline; }
.big { width: 100%; padding: 1rem; font-size: 1.05rem; margin-top: 1rem; }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 1rem 0 .4rem; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; accent-color: var(--accent); flex: none; }
input[type=text], input[type=number], input[type=datetime-local], select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; width: 100%;
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }

/* the three ways in */
.modes { display: grid; gap: 12px; margin: 8px 0 18px; }
.mode { display: flex; align-items: center; gap: 14px; padding: 18px; font-size: 1.15rem; font-weight: 600; text-align: left; background: var(--surface); border: 1px solid var(--line); }
.mode svg { width: 30px; height: 30px; flex: none; stroke: var(--accent); }
.mode small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.mode:active { transform: scale(.99); }

/* waiting: a ring that counts down */
.ring-box { position: relative; width: 150px; height: 150px; margin: 8px auto 10px; }
.ring { width: 150px; height: 150px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: var(--line); }
.ring .arc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring.spin { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(270deg); } }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text b { font-size: 2.4rem; font-variant-numeric: tabular-nums; line-height: 1; }
.ring-text small { color: var(--muted); }
.progress { width: 100%; max-width: 18rem; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }

/* a picture with its people and where the model looks */
.stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; line-height: 0; }
.stage img, .stage video, .stage canvas.picture { width: 100%; height: auto; display: block; }
.stage canvas.heat { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; }
.person { position: absolute; border: 2px solid var(--accent); border-radius: 8px; pointer-events: none; }
.person b { position: absolute; left: -2px; bottom: 100%; margin-bottom: 3px; background: var(--accent); color: #1a0710; font-size: .8rem; line-height: 1.3; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.person.best { border-color: var(--gold); }
.person.best b { background: var(--gold); }

.score { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 2px; }
.score b { font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.zone { font-size: 1.2rem; font-weight: 650; }
.zone small { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: 6px; }
.levels { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0 4px; background: var(--line); }
.levels span { height: 100%; }
.blocked { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin: 12px 0; }

/* trimming a long video */
.strip { position: relative; display: flex; height: 64px; border-radius: 10px; overflow: hidden; margin: 12px 0 6px; background: var(--surface); touch-action: none; user-select: none; }
.strip canvas { flex: 1; min-width: 0; height: 100%; object-fit: cover; opacity: .55; }
.window { position: absolute; top: 0; bottom: 0; border: 3px solid var(--accent); border-radius: 10px; background: rgba(255, 92, 138, .12); cursor: grab; }
.window .handle { position: absolute; top: 0; bottom: 0; width: 18px; cursor: ew-resize; }
.window .handle::after { content: ""; position: absolute; top: 30%; bottom: 30%; left: 7px; width: 4px; border-radius: 2px; background: var(--accent); }
.window .l { left: -10px; } .window .r { right: -10px; }
#trim-video { width: 100%; max-height: 46vh; border-radius: var(--radius); background: #000; }

/* timeline of a video */
.chart { width: 100%; height: 150px; display: block; margin-top: 10px; touch-action: pan-y; }
.chart .band { opacity: .08; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); }
.chart .cursor { stroke: var(--gold); stroke-width: 1.5; }
.chart text { fill: var(--muted); font-size: 10px; }

/* the camera */
.live { position: relative; }
.live video { transform: scaleX(-1); }
.live.rear video { transform: none; }
.live-score { position: absolute; left: 12px; bottom: 12px; padding: 8px 12px; border-radius: 12px; background: rgba(13, 11, 18, .72); backdrop-filter: blur(6px); line-height: 1.2; }
.live-score b { font-size: 2rem; font-variant-numeric: tabular-nums; }
.live-state { position: absolute; right: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(13, 11, 18, .72); font-size: .8rem; line-height: 1.4; }
.trace { width: 100%; height: 60px; display: block; margin-top: 8px; }
.trace path { fill: none; stroke: var(--accent); stroke-width: 2; }

/* the owner's dashboard */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { padding: .5rem .9rem; background: transparent; color: var(--muted); }
.tabs button.on { background: var(--raised); color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 10px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter div { height: 100%; background: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--raised); }
.pill.active { background: rgba(91, 156, 255, .18); color: var(--blue); }
.pill.expired, .pill.revoked { color: var(--muted); }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); align-items: end; }
.form label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: flex; gap: 6px; align-items: center; color: var(--text); }
.made { display: flex; gap: 8px; align-items: center; word-break: break-all; }
.made code { flex: 1; background: var(--raised); padding: 10px; border-radius: 10px; font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 9; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: .3rem .6rem; font-size: .8rem; }
.nowrap { white-space: nowrap; }
th { white-space: nowrap; }

/* every upload, for the owner */
.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 10px; margin-top: 12px; }
.upload { display: grid; gap: 2px; align-content: start; padding: 0 0 10px; text-align: left; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.upload > img, .upload > .blank { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #000; margin-bottom: 6px; }
.upload > .blank { display: grid; place-items: center; padding: 0 12px; text-align: center; color: var(--muted); font-size: .85rem; }
.upload.explicit > .blank { color: var(--error); }
.upload > span:not(.blank) { padding: 0 10px; }
.upload .sc { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.sc.z0 { color: #8e88a0; } .sc.z1 { color: #b5bac4; } .sc.z2 { color: #f4a6c4; } .sc.z3 { color: #ff5c8a; } .sc.z4 { color: #ffd166; }
.tag { display: inline-block; padding: 1px 8px; margin-left: 6px; border-radius: 999px; font-size: .75rem; background: var(--raised); color: var(--muted); vertical-align: middle; }
dialog.viewer { width: min(64rem, 96vw); max-height: 94vh; padding: 12px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); }
dialog.viewer::backdrop { background: rgba(0, 0, 0, .75); }
.viewer .bar { align-items: flex-start; }
.viewer .stage img { max-height: 56vh; object-fit: contain; }
.frames { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; }
.frames button { flex: none; display: grid; gap: 2px; width: 76px; padding: 0; background: none; color: var(--muted); font-size: .75rem; text-align: center; }
.frames img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; }
.frames button.on img { border-color: var(--accent); }
