:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1c2630;
  --muted: #65727f;
  --border: #d5dce3;
  --accent: #0b6e8a;
  --accent-text: #ffffff;
  --box: #ff3b30;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --selected: #ffd60a;
  --tick: #ff8a00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
header h1 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }

.progress {
  width: 180px;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
#bar { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.toggle { display: flex; gap: 4px; align-items: center; }
header .primary { margin-left: auto; }

button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
kbd {
  font: 11px ui-monospace, monospace;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 2px;
  background: var(--bg);
  color: var(--text);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
}

.viewer, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}

.images { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
figure { margin: 0; }
figcaption { color: var(--muted); font-size: 12px; margin-top: 4px; }
.crop-wrap img {
  display: block;
  width: 260px;
  height: 200px;
  object-fit: contain;
  background: #0d1b24;
  border-radius: 6px;
}
.frame-fig { flex: 1; min-width: 280px; }
.frame-wrap { position: relative; display: inline-block; max-width: 100%; }
.frame-wrap img { display: block; max-width: 100%; max-height: 46vh; border-radius: 6px; }
#box {
  position: absolute;
  border: 2px solid var(--box);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
  pointer-events: none;
}

.meta { margin: 10px 0; color: var(--muted); }
.strip-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.filmstrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 2px;
}
.filmstrip figure { flex: none; text-align: center; cursor: pointer; position: relative; }
.filmstrip .tick {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 4px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 13px;
  line-height: 16px;
}
.filmstrip figure.ticked .tick { background: var(--tick); border-color: var(--tick); }
.filmstrip figure.ticked .tick::after { content: "✓"; }
.filmstrip figure.ticked img { border-color: var(--tick); }
.filmstrip img {
  display: block;
  width: 92px;
  height: 70px;
  object-fit: contain;
  background: #0d1b24;
  border: 3px solid transparent;
  border-radius: 6px;
}
.filmstrip figure.selected img { border-color: var(--selected); }
.filmstrip figure.new-tracklet { margin-left: 10px; }
.filmstrip figcaption { white-space: nowrap; }

.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; }
.card-nav { display: flex; justify-content: space-between; align-items: center; }
.badge { margin-top: 10px; padding: 6px 8px; border-radius: 6px; background: var(--bg); min-height: 1em; }
.badge.done { background: #e3f4ea; color: var(--ok); }
.badge.skipped { background: #fff3df; color: var(--warn); }

.guesses { display: grid; gap: 6px; }
.guesses button { display: flex; justify-content: space-between; gap: 8px; text-align: left; }
.guesses .pct { color: var(--muted); }
.template-hint { margin-top: 6px; color: var(--accent); font-weight: 600; }
.guess-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.guess-head select { font-size: 12px; }
.family-step { margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--accent); }
.family-step .hint { margin: 0; }
.guesses .of { color: var(--muted); font-size: 12px; }
.rig-hint { margin-top: 6px; color: var(--muted); }
.rig-batch { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.flags { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--warn); border-radius: 6px; background: #fff3df; }
.flags strong { color: var(--warn); }
.flags p { margin: 6px 0 0; }
.pieces figcaption { white-space: normal; line-height: 1.25; }
.meta .call { color: var(--muted); cursor: pointer; text-decoration: underline dotted; }
.tag { margin-left: 6px; padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.guesses button.recorded { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }

.species-row { display: flex; gap: 6px; }
.species-row input { flex: 1; min-width: 0; }
input, select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.other-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
details { margin-top: 16px; }
details label { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 8px; }
details label input, details label select { width: 100%; min-width: 0; }
details label[hidden] { display: none; }
#message { min-height: 1.4em; margin-top: 12px; }
#message.error { color: var(--box); }
#message.ok { color: var(--ok); }
.empty { text-align: center; padding: 60px 16px; }

/* Look-alikes and still objects */
.like-hint { margin-top: 8px; padding: 6px 10px; border-left: 3px solid var(--ok); color: var(--text); }
.like-hint .muted { color: var(--muted); }
.quick { display: flex; gap: 8px; margin-bottom: 6px; }
.quick figure { margin: 0; flex: 1; }
.quick img { display: block; width: 100%; height: 120px; object-fit: contain; background: #000; border-radius: 6px; }
.quick figcaption { font-size: 12px; color: var(--muted); }
.like-hint p { margin: 0; }
.linkish { border: none; background: none; padding: 0; color: var(--muted); text-decoration: underline dotted; cursor: pointer; font: inherit; }
.grid-panel { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.45); }
.grid-panel[hidden] { display: none; }
.grid-box { width: min(1200px, 96vw); height: 92vh; display: flex; flex-direction: column; padding: 14px 16px; border-radius: 8px; background: var(--panel); color: var(--text); }
.grid-box h2 { margin: 0 0 4px; }
.grid-top { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.grid-compare { display: flex; gap: 10px; flex: none; }
.grid-compare figure { margin: 0; width: 220px; }
.grid-compare img { display: block; width: 220px; height: 150px; object-fit: contain; background: #000; border-radius: 6px; }
.grid-compare figcaption { font-size: 12px; color: var(--muted); padding-top: 2px; }
/* The list scrolls inside the box; its rows keep their height (they used to be squeezed). */
.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 4px 4px 0; }
.grid-scroll h3 { margin: 12px 0 6px; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; align-content: start; }
.grid figure { position: relative; margin: 0; border: 2px solid var(--border); border-radius: 6px; cursor: pointer; }
.grid .pics { display: flex; gap: 2px; height: 130px; background: #000; border-radius: 4px 4px 0 0; overflow: hidden; }
.grid .pics img { flex: 1; min-width: 0; height: 100%; object-fit: contain; }
.grid figcaption { padding: 3px 6px; font-size: 12px; color: var(--muted); }
.grid figure.ticked { border-color: var(--ok); }
.grid figure.ticked::after { content: "✓"; position: absolute; top: 4px; right: 8px; color: var(--ok); font-weight: 700; text-shadow: 0 0 3px #000; }
.grid-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 10px; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181f;
    --panel: #18222b;
    --text: #e6edf3;
    --muted: #93a1ad;
    --border: #2c3a46;
    --accent: #1f9bc0;
  }
  .badge.done { background: #173826; }
  .badge.skipped { background: #3a2a10; }
  .flags { background: #3a2a10; }
}

/* Follow a fish (follow.html) */
.follow-main { grid-template-columns: minmax(0, 1fr) 320px; }
.back-link { margin-left: auto; color: var(--accent); }
.phase { padding: 2px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.phase.forward { border-color: var(--accent); color: var(--accent); }
.phase.backward { border-color: var(--warn); color: var(--warn); }
.phase.done { border-color: var(--ok); color: var(--ok); }
.stage { position: relative; display: inline-block; max-width: 100%; overflow: hidden; border-radius: 6px; cursor: crosshair; line-height: 0; }
.zoomer { position: relative; transition: transform .15s; }
.zoomer img { display: block; max-width: 100%; max-height: calc(100vh - 170px); }
.fbox {
  position: absolute;
  padding: 0;
  border: 2px solid #4fd1ff;
  border-radius: 2px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55);
  cursor: pointer;
}
.fbox::after { content: ""; position: absolute; inset: -6px; }  /* easier to hit a small box */
.fbox:hover { border-color: var(--selected); background: rgba(255, 214, 10, .12); }
.fbox.faint { border-style: dashed; border-width: 1px; }
.fbox.taken { border-color: #b98cff; }
.fbox.focus { border-color: var(--box); border-width: 3px; }
.fbox span {
  position: absolute; left: 0; top: -16px; font: 11px/14px system-ui, sans-serif;
  background: #b98cff; color: #fff; padding: 0 3px; border-radius: 3px; white-space: nowrap;
}
.ring {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 2px dashed var(--selected); border-radius: 50%; pointer-events: none;
}
.key-list { padding-left: 18px; margin: 6px 0; }
.key-list li { margin: 4px 0; }
.warn { color: var(--warn); }
#done .actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) { .follow-main { grid-template-columns: 1fr; } }
