:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #dde1e6;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --error: #b91c1c;
  --hit: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1b1e24;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2c3139;
    --accent: #5b8def;
    --ok: #4ade80;
    --error: #f87171;
    --hit: #fb923c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.muted { color: var(--muted); }

/* navigation */
.nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.tabs { display: flex; gap: .5rem; }
.tab {
  padding: .45rem 1rem; border-radius: 6px; border: 1px solid var(--border);
  color: var(--text); font-weight: 600;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tab:hover { text-decoration: none; }
.account { margin-left: auto; display: flex; align-items: center; gap: 1rem; }

/* forms */
input, select, button {
  font: inherit; color: inherit;
  padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
button, .button {
  display: inline-block; cursor: pointer;
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600;
}
.button:hover { text-decoration: none; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 400; }
button.danger { background: none; border-color: var(--error); color: var(--error); }
form.inline { display: inline-flex; gap: .4rem; margin: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem;
  display: flex; flex-direction: column; gap: .8rem;
}
.card label { display: flex; flex-direction: column; gap: .25rem; }
.narrow { max-width: 380px; margin: 2rem auto 0; }
.narrow.center { text-align: center; margin-top: 1rem; }

.search {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .9rem;
}
.search label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }

.flash { padding: .6rem .9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.error { border-color: var(--error); color: var(--error); }

/* detections grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  color: var(--text); display: flex; flex-direction: column;
}
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.tile-body { padding: .6rem .75rem; display: flex; flex-direction: column; gap: .15rem; }

/* tables */
.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.list th, .list td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.list th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid currentColor; }
.badge.hit { color: var(--hit); }
.badge.error { color: var(--error); }

/* player pages */
video { width: 100%; max-height: 75vh; background: #000; border-radius: 8px; display: block; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1rem 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.clips { padding-left: 1.2rem; }

@media (max-width: 640px) {
  .account { margin-left: 0; width: 100%; }
  .list th:nth-child(3), .list td:nth-child(3) { display: none; }
}

/* review of a detection */
.review { margin: 1.5rem 0; }
.review h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.frame { width: 100%; height: auto; display: block; border-radius: 8px; background: #000; }
.frame .obj { fill: none; stroke-width: 6; }
.frame .obj-person { stroke: #3b82f6; }
.frame .obj-dog { stroke: #f97316; }
.frame .obj-none { stroke: #9ca3af; stroke-dasharray: 18 12; }
.frame .num-bg { fill: #facc15; stroke: #111; stroke-width: 3; }
.frame .num { fill: #111; font: 700 40px system-ui, sans-serif; text-anchor: middle; }
.review-form { display: flex; flex-direction: column; gap: .6rem; }
.obj-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.num-chip {
  display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem;
  border-radius: 50%; background: #facc15; color: #111; font-weight: 700;
}
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
button.secondary { background: var(--surface); color: var(--accent); }
button[disabled] { opacity: .5; cursor: not-allowed; }
.badge.ok { color: var(--ok); }
.log {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .6rem;
  max-height: 22rem; overflow: auto; font-size: .8rem; white-space: pre-wrap;
}

/* download / share */
.media-actions { margin: 1rem 0 0; align-items: center; }
.button.secondary { background: var(--surface); color: var(--accent); }
a.button { padding: .4rem .6rem; border: 1px solid var(--accent); border-radius: 6px; line-height: normal; }
.ttl { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .9rem; }
.ttl select { color: var(--text); }
.share-link { width: 100%; margin: .6rem 0 1rem; font-family: ui-monospace, monospace; font-size: .85rem; }
td .share-link { margin: 0; min-width: 16rem; }

/* review result */
.review-status {
  display: flex; flex-direction: column; gap: .2rem; margin: 0 0 1rem; padding: .7rem .9rem;
  border: 1px solid var(--ok); border-left-width: 5px; border-radius: 6px; color: var(--text);
}
.review-status strong { color: var(--ok); }
.review-status.corrected { border-color: var(--hit); }
.review-status.corrected strong { color: var(--hit); }
.review-status.just-saved { font-size: 1.05rem; }
.review-status span { color: var(--muted); font-size: .9rem; }

/* "All correct": red until the clip is reviewed, green once confirmed */
button.confirm-todo { background: var(--error); border-color: var(--error); color: #fff; }
button.confirm-done { background: var(--ok); border-color: var(--ok); color: #fff; }

/* review buttons: outlined in their colour, filled for the answer that is saved */
button.rv { background: var(--surface); font-weight: 600; }
button.rv-confirm { border-color: var(--ok); color: var(--ok); }
button.rv-save { border-color: var(--hit); color: var(--hit); }
button.rv-confirm.todo { background: var(--error); border-color: var(--error); color: var(--bg); }
button.rv-confirm.on { background: var(--ok); color: var(--bg); }
button.rv-save.on { background: var(--hit); color: var(--bg); }
.hint { margin: .5rem 0 0; font-size: .9rem; }
