/* Cheesy Labeling. Team 254 blue and cheese yellow, scoreboard type.
   One display face (Barlow Condensed) for standings and numbers, Barlow for everything else. */
:root {
  --paper: #eef2f7;
  --surface: #ffffff;
  --ink: #0b2545;
  --dim: #5a6a80;
  --line: #d3dbe6;
  --blue: #0066b3;
  --blue-deep: #004a85;
  --cheese: #ffc629;
  --danger: #c2302a;
  --ok: #1d7a4d;
  --stage: #081a30;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: "Barlow", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font: 700 44px/1 var(--display); letter-spacing: 0.005em; }
h2 { font: 600 24px/1.1 var(--display); }
h3 { font: 600 15px/1.3 var(--text); margin-bottom: 6px; }
p { margin: 0; }
a { color: var(--blue); }
.dim { color: var(--dim); }
.small { font-size: 13px; font-weight: 400; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.empty { color: var(--dim); padding: 20px 0; }
kbd {
  font: 600 11px var(--text);
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
  opacity: 0.75;
}
code { font: 600 15px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper); padding: 2px 6px; border-radius: 3px; user-select: all; }

/* ---------- controls ---------- */
.btn {
  font: 500 15px var(--text);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn.quiet { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 13px 18px; font-size: 17px; width: 100%; justify-content: center; }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
:focus-visible { outline: 3px solid var(--cheese); outline-offset: 2px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--dim); }
input, select, textarea {
  font: 400 16px var(--text);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  min-width: 0;
}
input[type="color"] { padding: 2px; width: 44px; height: 40px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--blue); flex: none; }
input[type="file"] { display: none; }
.check { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 15px; font-weight: 400; color: var(--ink); padding: 3px 0; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--surface); }
.seg > * {
  font: 500 14px var(--text);
  color: var(--dim);
  background: none;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
}
.seg > *:last-child { border-right: 0; }
.seg > .on { background: var(--ink); color: #fff; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(560px, 90vw);
  padding: 12px 18px;
  border-radius: 4px;
  color: #fff;
  background: var(--danger);
  z-index: 50;
  box-shadow: 0 6px 24px rgba(8, 26, 48, 0.3);
}
.toast.ok { background: var(--ok); }

/* ---------- top bar ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 56px;
  background: var(--ink);
  color: #fff;
}
.brand { font: 700 26px/1 var(--display); color: var(--cheese); text-decoration: none; letter-spacing: 0.01em; }
.nav { display: flex; gap: 4px; align-self: stretch; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #c9d6e6;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 4px solid transparent;
  border-top: 4px solid transparent;
}
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--cheese); }
.who { color: #c9d6e6; font-size: 14px; }
.topbar .btn.quiet { color: #fff; border-color: #36506f; }
.topbar .btn.quiet:hover { border-color: #fff; }
#view { flex: 1; min-height: 0; overflow: auto; }

/* ---------- sign in ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1.2fr 1fr; }
.login-mark {
  background: var(--ink);
  color: #fff;
  padding: clamp(32px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 24px;
}
.login-mark h1 { font-size: clamp(72px, 13vw, 190px); line-height: 0.84; color: var(--cheese); text-transform: uppercase; }
.login-mark p { max-width: 34ch; font-size: 19px; color: #c9d6e6; }
.login-side { padding: clamp(32px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; gap: 12px; max-width: 520px; }
.login-side h2 { font-size: 36px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.form-error { color: var(--danger); font-weight: 500; }

/* ---------- leaderboard home ---------- */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 48px; padding: 40px clamp(20px, 4vw, 56px) 64px; max-width: 1400px; margin: 0 auto; }
.standing { font-size: clamp(56px, 8.5vw, 132px); line-height: 0.88; text-transform: uppercase; letter-spacing: -0.005em; }
.standing-sub { font-size: 20px; margin-top: 14px; max-width: 46ch; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 44px 0 8px; flex-wrap: wrap; }
.board { list-style: none; margin: 0; padding: 0; border-top: 3px solid var(--ink); }
.board-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 96px 92px 96px;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
}
.board-row .rank { font: 600 30px/1 var(--display); color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.board-row .who-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.board-row .name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .bar { display: block; height: 8px; background: var(--line); }
.board-row .bar i { display: block; height: 100%; width: var(--w); background: var(--blue); transform-origin: left; animation: grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.board-row .count { font: 700 34px/1 var(--display); text-align: right; font-variant-numeric: tabular-nums; }
.board-row .pace, .board-row .last { font-size: 13px; text-align: right; white-space: nowrap; }
.board-row.first .rank { color: var(--ink); }
.board-row.first .bar i { background: var(--cheese); }
.board-row.me { background: var(--surface); box-shadow: -6px 0 0 var(--blue), 6px 0 0 var(--surface); }
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .board-row .bar i { animation: none; } }

.home-side { display: flex; flex-direction: column; gap: 12px; padding-top: 10px; }
.home-side h2 { margin-bottom: 4px; }
.project {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  color: var(--ink);
  text-decoration: none;
}
.project:hover { border-color: var(--ink); border-left-color: var(--cheese); }
.project-title { font: 600 21px/1.15 var(--display); }
.meter { display: block; height: 6px; background: var(--line); min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--blue); }

/* ---------- generic pages (manage, project picker) ---------- */
.page { padding: 32px clamp(20px, 4vw, 56px) 64px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page.narrow { max-width: 640px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.manage-body { display: flex; flex-direction: column; gap: 20px; }
.lede { font-size: 17px; max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--line); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.notice { background: #fff7d6; border-left: 6px solid var(--cheese); padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.invite-list { display: flex; flex-direction: column; gap: 8px; }
.invite { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; }
.invite-link { font: 400 14px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper); }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--dim); padding: 6px 12px 6px 0; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.table td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .n { text-align: right; font-variant-numeric: tabular-nums; }
.table td.n { font: 600 20px/1 var(--display); }
.table select { padding: 6px 8px; font-size: 14px; }
.person { display: flex; flex-direction: column; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font: 500 13px var(--text); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.shot { margin: 0; }
.shot-img { position: relative; background: var(--stage); line-height: 0; min-height: 60px; }
.shot-img img { width: 100%; height: auto; display: block; }
.shot-box { position: absolute; border: 2px solid var(--c); }
.shot.skipped .shot-img { opacity: 0.45; }
.shot figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding-top: 5px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.project-picks { padding: 4px 0 0 26px; max-height: 220px; overflow-y: auto; }
.uploader { display: inline-flex; align-items: center; gap: 10px; }
.uploader label { flex-direction: row; color: var(--ink); cursor: pointer; }
.label-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.label-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px 64px auto; gap: 8px; align-items: center; }
.label-row .key { text-align: center; text-transform: uppercase; }

/* ---------- labeling workspace ---------- */
body[data-route="label"] #view { overflow: hidden; }
.work { display: flex; height: 100%; min-height: 0; }
.viewport { flex: 1; min-width: 0; position: relative; display: flex; overflow: auto; padding: 16px; background: var(--stage); }
.stage { position: relative; flex: none; margin: auto; line-height: 0; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.stage.loading img { visibility: hidden; }
.boxes { position: absolute; inset: 0; }
.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  color: #c9d6e6;
  font-size: 18px;
  pointer-events: none;
}
.stage-msg > * { pointer-events: auto; max-width: 44ch; }
.box { position: absolute; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); line-height: 1.2; }
.box.ai { border-style: dashed; }
.box.selected { border-style: solid; background: color-mix(in srgb, var(--c) 22%, transparent); box-shadow: 0 0 0 1px #fff; cursor: move; z-index: 5; }
.box .tag {
  position: absolute;
  left: -2px;
  bottom: 100%;
  background: var(--c);
  color: #fff;
  font: 600 12px/1.3 var(--text);
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}
.box.near-top .tag { bottom: auto; top: -2px; }
.box .del {
  position: absolute;
  right: -2px;
  bottom: 100%;
  width: 22px;
  height: 18px;
  padding: 0;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
}
.box.near-top .del { bottom: auto; top: -2px; }
.handle { position: absolute; width: 11px; height: 11px; background: #fff; border: 1px solid #000; margin: -6px 0 0 -6px; }
.handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.handle.n { left: 50%; top: 0; cursor: ns-resize; }
.handle.ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle.e { left: 100%; top: 50%; cursor: ew-resize; }
.handle.se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle.s { left: 50%; top: 100%; cursor: ns-resize; }
.handle.sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle.w { left: 0; top: 50%; cursor: ew-resize; }

.side { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; }
.panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.grow-panel { flex: 1; min-height: 190px; }
.side-title { font-size: 22px; }
.session { font: 600 20px/1 var(--display); color: var(--blue); }
details.panel { display: block; }
details.panel summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.instructions { margin-top: 8px; font-size: 14px; color: var(--dim); white-space: pre-wrap; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-btn {
  font: 500 15px var(--text);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 8px solid var(--c);
  border-radius: 4px;
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.label-btn.active { background: color-mix(in srgb, var(--c) 18%, #fff); border-color: var(--c); font-weight: 600; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choice-btn {
  font: 500 14px var(--text);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.choice-btn.on { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.box-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 44px; }
.box-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; }
.box-row:hover { background: var(--paper); }
.box-row.selected { border-color: var(--ink); background: var(--paper); }
.box-row .swatch { width: 12px; height: 12px; background: var(--c); flex: none; }
.help { line-height: 1.8; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-mark { justify-content: flex-start; }
  .home { grid-template-columns: 1fr; gap: 32px; }
  .board-row { grid-template-columns: 36px minmax(0, 1fr) 72px; }
  .board-row .pace, .board-row .last { display: none; }
  .add-form, .cols, .invite { grid-template-columns: 1fr; }
  .work { flex-direction: column; }
  .side { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 46%; }
  .topbar { gap: 12px; padding: 0 12px; }
  .who { display: none; }
}
