:root {
  --bg: #f2f6fb;
  --bg-tint: #e8f1fb;
  --panel: #ffffff;
  --panel-2: #eef4fb;
  --text: #17202c;
  --muted: #6b7c93;
  --border: #dce6f2;

  --accent: #2b8ae6;          /* light blue — primary */
  --accent-strong: #1a6fc4;
  --accent-soft: #e7f2fd;

  --cam-a: #2b8ae6;
  --cam-b: #6f5be6;

  --green: #12a06a;
  --green-soft: #e6f7f0;
  --red: #e04a4f;
  --red-soft: #fdecec;

  --shadow-sm: 0 1px 2px rgba(20, 40, 70, .06), 0 1px 3px rgba(20, 40, 70, .04);
  --shadow-md: 0 4px 16px rgba(20, 40, 70, .08), 0 1px 3px rgba(20, 40, 70, .05);
  --shadow-lg: 0 18px 48px rgba(20, 40, 70, .18), 0 2px 8px rgba(20, 40, 70, .08);

  /* Apple-ish easing: decisive out, gentle settle */
  --ease-out: cubic-bezier(.32, .72, 0, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --footer-h: 118px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-tint) 0%, var(--bg) 220px);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 6;
}
header h1 {
  font-size: 15px; margin: 0; font-weight: 600; white-space: nowrap;
  letter-spacing: -.01em;
}
.progress-wrap { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.progress-bar {
  flex: 1; height: 6px; background: var(--panel-2);
  border-radius: 999px; overflow: hidden; max-width: 420px;
}
#progress-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, #57b0f5 100%);
  transition: width .45s var(--ease-out);
}
#progress-text { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.header-actions { display: flex; align-items: center; gap: 8px; }
#btn-help {
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  font-weight: 700; color: var(--muted);
}
#btn-list { padding: 7px 15px; font-size: 13px; font-weight: 500; }
/* Who is labeling — quiet, but visible enough to catch a shared-laptop mixup. */
.who {
  font-size: 12px; color: var(--muted); max-width: 20ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#btn-signout { padding: 7px 12px; font-size: 12px; color: var(--muted); }
@media (max-width: 700px) { .who { display: none; } }

main { flex: 1; display: flex; flex-direction: column; padding: 18px 20px 0; min-height: 0; }
.pair-grid {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 330px) 1fr;
  grid-template-areas: "a gap b";
  gap: 18px;
  flex: 1;
  min-height: 0;
  will-change: transform, opacity;
}
#card-a { grid-area: a; }
#card-b { grid-area: b; }
.gap-column { grid-area: gap; }

.snippet-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .3s var(--ease-out), transform .3s var(--ease-out);
}
.snippet-card:hover { box-shadow: var(--shadow-md); }
.snippet-card h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; text-align: center;
}
#card-a h2 { color: var(--cam-a); }
#card-b h2 { color: var(--cam-b); }
.img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
  cursor: zoom-in;
}
.img-wrap img {
  max-width: 100%; max-height: 100%; height: 100%;
  object-fit: contain; display: block;
  transition: transform .35s var(--ease-out);
}
.img-wrap:hover img { transform: scale(1.02); }
.img-wrap.img-error::after {
  content: "image not found";
  color: var(--red);
  font-size: 13px;
}
dl.meta { margin: 12px 0 0; font-size: 13px; }
dl.meta div { display: flex; justify-content: space-between; padding: 3px 0; gap: 12px; }
dl.meta dt { color: var(--muted); margin: 0; }
dl.meta dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }

.gap-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 0;
}
.gap-badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.gap-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
}
.gap-value {
  font-size: 22px; font-weight: 650; margin-top: 4px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  color: var(--accent-strong);
}
.pair-id { font-size: 12px; color: var(--muted); margin-top: auto; padding-bottom: 6px; }
.ctx-hint { font-size: 12px; color: var(--muted); text-align: center; }

#context-view {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: ctxIn .3s var(--ease-out);
}
#context-view[hidden] { display: none; }
@keyframes ctxIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.ctx-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 500;
}
#ctx-close {
  width: 24px; height: 24px; padding: 0; font-size: 12px;
  border-radius: 8px; color: var(--muted);
}
.ctx-frame { position: relative; }
.ctx-frame img { display: block; width: 100%; height: auto; border-radius: 10px; }
#ctx-bbox {
  position: absolute;
  border: 2.5px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(12, 26, 45, .20);
  animation: boxIn .34s var(--ease-out);
  pointer-events: none;
}
@keyframes boxIn {
  from { opacity: 0; transform: scale(1.12); }
  to { opacity: 1; transform: none; }
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0 20px;
  gap: 24px;
  flex-wrap: wrap;
}
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out),
              background-color .18s var(--ease-out), filter .18s var(--ease-out);
}
button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
button:active { transform: translateY(0) scale(.97); box-shadow: var(--shadow-sm); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: default; transform: none; }
kbd {
  font-family: inherit;
  font-size: 11px;
  background: rgba(20, 40, 70, .07);
  border-radius: 5px;
  padding: 2px 6px;
  color: inherit;
  opacity: .75;
}
.label-btn kbd { margin-left: 8px; }
.nav-group { display: flex; align-items: center; gap: 10px; }
#position-text { font-size: 13px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.help-hint { font-size: 12px; color: var(--muted); }
.label-group { display: flex; gap: 12px; }
.label-btn {
  font-size: 16px; font-weight: 600; padding: 14px 34px;
  letter-spacing: -.01em; border-radius: 14px;
}
.label-btn.same { background: var(--green-soft); border-color: rgba(18,160,106,.35); color: var(--green); }
.label-btn.diff { background: var(--red-soft); border-color: rgba(224,74,79,.35); color: var(--red); }
.label-btn.skip { color: var(--muted); }
.label-btn.selected { box-shadow: 0 0 0 2px currentColor, var(--shadow-sm); }
.label-btn.pulse { animation: pulse .34s var(--ease-out); }
@keyframes pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.07); filter: brightness(1.04); }
  100% { transform: scale(1); }
}

/* --- pair transition: cards leave toward the decision, next slides in --- */
.pair-grid.exit-left  { animation: exitLeft .17s var(--ease-in) forwards; }
.pair-grid.exit-right { animation: exitRight .17s var(--ease-in) forwards; }
.pair-grid.exit-down  { animation: exitDown .17s var(--ease-in) forwards; }
@keyframes exitLeft  { to { opacity: 0; transform: translateX(-34px) scale(.985); } }
@keyframes exitRight { to { opacity: 0; transform: translateX(34px) scale(.985); } }
@keyframes exitDown  { to { opacity: 0; transform: translateY(16px) scale(.98); } }
.pair-grid.enter-left  { animation: enterLeft .34s var(--ease-out); }
.pair-grid.enter-right { animation: enterRight .34s var(--ease-out); }
.pair-grid.enter-down  { animation: enterDown .34s var(--ease-out); }
@keyframes enterLeft  { from { opacity: 0; transform: translateX(34px) scale(.99); } }
@keyframes enterRight { from { opacity: 0; transform: translateX(-34px) scale(.99); } }
@keyframes enterDown  { from { opacity: 0; transform: translateY(-12px) scale(.99); } }

#empty-state { margin: 80px auto; max-width: 520px; text-align: center; color: var(--muted); }
#empty-state code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }
#done-banner {
  position: fixed; bottom: 96px; left: 50%;
  background: var(--green); color: #fff; font-weight: 600;
  padding: 11px 24px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 5;
  animation: bannerIn .45s var(--ease-out);
}
@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, 14px) scale(.94); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
#done-banner { transform: translateX(-50%); }

#list-overlay, #help-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 32, 54, .34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  animation: fadeIn .2s var(--ease-out);
}
#list-overlay[hidden], #help-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.list-card, .help-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: sheetIn .34s var(--ease-out);
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.list-card {
  width: min(680px, 94vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.list-header h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
#btn-list-close, #btn-help-close { color: var(--muted); }
#list-rows { overflow-y: auto; padding: 8px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 8px 10px; margin: 2px 0;
  background: none; border: 1px solid transparent; border-radius: 12px;
  font-size: 13px; color: var(--text);
  box-shadow: none;
  transition: background-color .18s var(--ease-out), transform .18s var(--ease-out);
}
.list-row:hover { background: var(--panel-2); transform: none; box-shadow: none; }
.list-row.current { border-color: var(--accent); background: var(--accent-soft); }
.list-row img {
  height: 44px; width: 22px; object-fit: cover;
  border-radius: 6px; background: var(--panel-2);
}
.list-row .row-id { font-variant-numeric: tabular-nums; color: var(--muted); width: 70px; }
.list-row .row-cams { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .row-gap { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.chip.same { background: var(--green-soft); color: var(--green); }
.chip.different { background: var(--red-soft); color: var(--red); }
.chip.skip { background: var(--panel-2); color: var(--muted); }
.chip.todo { border: 1px solid var(--border); color: var(--muted); }

.help-card { padding: 24px 28px; max-width: 440px; width: 90%; }
.help-card h2 { margin: 0 0 14px; font-size: 16px; letter-spacing: -.01em; }
.help-card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-card td { padding: 6px 0; }
.help-card td:first-child { width: 110px; color: var(--muted); white-space: nowrap; }
.help-card p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.help-card button { width: 100%; margin-top: 8px; }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  header { padding: 10px 12px; gap: 10px; }
  header h1 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  main { padding: 12px 10px 0; }
  .pair-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "gap gap" "a b";
    grid-template-rows: auto 1fr;
    gap: 10px;
  }
  .gap-column { flex-direction: row; justify-content: center; align-items: center; gap: 10px; }
  .gap-badge { width: auto; padding: 9px 18px; }
  .gap-value { font-size: 17px; margin-top: 2px; }
  .pair-id, .ctx-hint { display: none; }
  .snippet-card { padding: 8px; border-radius: 14px; }
  .snippet-card h2 { font-size: 11px; margin-bottom: 6px; }
  dl.meta { font-size: 11px; margin-top: 6px; }
  .img-wrap { cursor: pointer; }

  /* context view becomes a bottom sheet that clears the label buttons */
  #context-view {
    position: fixed; left: 8px; right: 8px; bottom: var(--footer-h);
    border-radius: 18px;
    padding: 12px;
    z-index: 8;
    box-shadow: var(--shadow-lg);
    animation: sheetUp .34s var(--ease-out);
  }
  @keyframes sheetUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }

  footer {
    gap: 10px; padding: 10px 0 14px;
    position: relative; z-index: 9;
  }
  .label-group { width: 100%; gap: 8px; }
  .label-btn { flex: 1; font-size: 15px; padding: 15px 8px; }
  .label-btn kbd, .help-hint { display: none; }
}

/* very narrow: the bar alone carries progress, and the title steps aside */
@media (max-width: 470px) {
  header h1 { font-size: 13px; max-width: 42%; }
  #progress-text { display: none; }
  .progress-bar { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
