/* Aladobe grading portal.
   A light table, not a website: chromatically silent neutral darks around the
   photograph; the model speaks in cool slate, the human in grease-pencil amber. */

:root {
  --bg0: #151517;        /* app ground */
  --bg1: #1c1c1f;        /* panels */
  --bg2: #242428;        /* raised / hover */
  --stage: #0d0d0e;      /* light-table surface behind the photo */
  --line: #2d2d32;
  --text: #e9e9e6;
  --dim: #98988f;
  --faint: #66665f;
  --machine: #7f8ea3;    /* the model: cool, quiet */
  --human: #f2a33c;      /* the human: grease pencil */
  --human-soft: rgba(242, 163, 60, .16);
  --danger: #b04a4a;
  --ui: "Archivo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg0);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 2px;
}

.view { min-height: 100vh; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

.wordmark {
  font-family: var(--ui);
  font-variation-settings: "wdth" 125;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .22em;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
}

/* ── buttons ─────────────────────────────────────────────── */

.btn {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #2b2b30; border-color: #3a3a40; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg2); }
.btn-accept {
  background: var(--human);
  border-color: var(--human);
  color: #1a1206;
  font-weight: 700;
}
.btn-accept:hover { background: #ffb554; border-color: #ffb554; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.holding { background: var(--bg2); border-color: var(--machine); }

:focus-visible { outline: 2px solid var(--machine); outline-offset: 1px; }

/* ── login ───────────────────────────────────────────────── */

#view-login { align-items: center; justify-content: center; }
.login-card {
  display: flex; flex-direction: column; gap: 14px;
  width: min(320px, 86vw);
  padding: 36px 32px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.login-card .wordmark { font-size: 20px; }
.login-sub { color: var(--dim); font-size: 12px; margin-top: -8px; }
.login-card input {
  background: var(--bg0); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; font-size: 14px; font-family: var(--mono);
  text-align: center;
}
.login-err { color: var(--danger); font-size: 12px; }

/* ── topbar ──────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg1);
  position: sticky; top: 0; z-index: 20;
}
.status-line {
  flex: 1;
  font-size: 11px;
  color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.status-line .ok { color: var(--machine); }
.status-line .warn { color: var(--human); }
.status-line .err { color: var(--danger); }
.add-form { display: flex; gap: 6px; }
.add-form input {
  width: 130px;
  background: var(--bg0); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 9px; font-size: 12px;
}

/* ── filters ─────────────────────────────────────────────── */

.filters { display: flex; gap: 8px; padding: 14px 20px 4px; flex-wrap: wrap; }
.chip {
  font-family: var(--ui); font-size: 12px; font-weight: 600;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 13px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); border-color: var(--machine); }
.chip .n { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-left: 4px; }
.chip.active .n { color: var(--machine); }

/* ── contact sheet ───────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding: 18px 20px 60px;
}

.card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
  position: relative;
}
.card:hover { border-color: #45454c; transform: translateY(-1px); }
.card .thumb {
  aspect-ratio: 3 / 2;
  background: var(--stage);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.is-skipped .thumb img, .card.is-error .thumb img { opacity: .38; filter: grayscale(.7); }

/* film-rebate caption: the frame's data, set like edge print */
.rebate {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--dim);
  border-top: 1px solid var(--line);
  background: #141416;
}
.rebate .fid { color: var(--text); font-weight: 500; }
.rebate .sep { color: var(--faint); }
.rebate .st { margin-left: auto; text-transform: uppercase; letter-spacing: .1em; font-size: 9px; }
.st-new { color: var(--faint); }
.st-predicting { color: var(--machine); }
.st-predicted { color: var(--machine); }
.st-accepted { color: var(--human); }
.st-skipped { color: var(--faint); }
.st-error { color: var(--danger); }

/* grease-pencil select mark on accepted frames */
.card .mark {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px;
  pointer-events: none;
}
.card .mark circle {
  fill: none;
  stroke: var(--human);
  stroke-width: 9;
  stroke-linecap: round;
  opacity: .92;
}
.card .touched-n {
  position: absolute; top: 12px; right: 42px;
  font-family: var(--mono); font-size: 10px; color: var(--human);
}

.grid-empty { padding: 80px 24px; text-align: center; max-width: 460px; margin: 0 auto; }
.grid-empty p:first-child { font-size: 16px; font-weight: 600; margin-bottom: 8px; }

/* ── editor ──────────────────────────────────────────────── */

.editor-topbar { gap: 14px; }
.editor-title { flex: 1; display: flex; gap: 12px; align-items: baseline; overflow: hidden; }
.editor-title #ed-id { font-size: 13px; font-weight: 600; }
.editor-title #ed-assignment { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-nav { display: flex; gap: 6px; align-items: center; }

#view-editor { height: 100vh; overflow: hidden; }

.editor-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 0;
}

.stage {
  background: var(--stage);
  display: flex; flex-direction: column;
  min-width: 0;
}
.stage-frame {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 22px;
  cursor: zoom-in;
  overflow: hidden;
}
.stage-frame.zoomed { overflow: auto; cursor: zoom-out; }
.stage-frame.zoomed #stage-img { max-width: none; max-height: none; margin: auto; }
#stage-img {
  max-width: 100%; max-height: calc(100vh - 160px);
  object-fit: contain;
  box-shadow: 0 0 0 1px #000, 0 18px 50px rgba(0,0,0,.55);
  background: #000;
}
#stage-img.dimmed { opacity: .55; }
.stage-tag {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bg0);
  background: var(--machine);
  border-radius: 3px;
  padding: 3px 10px;
}
.stage-tag.human { background: var(--human); }
.stage-msg {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  color: var(--dim); font-size: 13px; text-align: center; padding: 20px;
}
.stage-msg[hidden] { display: none; }

.grease-circle {
  position: absolute; top: 50%; left: 50%;
  width: 190px; height: 190px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.grease-circle circle {
  fill: none;
  stroke: var(--human);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 290;
  stroke-dashoffset: 290;
}
.grease-circle.draw circle { animation: grease .45s cubic-bezier(.5,.1,.4,1) forwards; }
@keyframes grease { to { stroke-dashoffset: 18; } }

.stage-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg1);
}
.render-ind { margin-left: auto; font-size: 11px; color: var(--faint); }
.render-ind.busy { color: var(--machine); }
.render-ind.busy::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--machine);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── parameter rail ──────────────────────────────────────── */

.rail {
  border-left: 1px solid var(--line);
  background: var(--bg1);
  display: flex; flex-direction: column;
  min-height: 0;
}
#params { flex: 1; overflow-y: auto; padding: 6px 18px 14px; }

.pgroup { margin-top: 16px; }
.pgroup-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.pgroup-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.prow { padding: 5px 0 7px; }
.prow-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 4px;
}
.prow-name { font-size: 12.5px; font-weight: 500; color: var(--text); }
.prow.touched .prow-name { color: var(--human); }
.reset-dot {
  visibility: hidden;
  width: 14px; height: 14px;
  border: none; background: transparent;
  color: var(--human);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  padding: 0;
}
.prow.touched .reset-dot { visibility: visible; }
.prow-val {
  margin-left: auto;
  width: 64px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  padding: 1px 5px;
}
.prow-val:hover, .prow-val:focus { border-color: var(--line); background: var(--bg0); outline: none; }
.prow.touched .prow-val { color: var(--human); }

/* slider: custom track so the prediction tick + human delta can live on it */
.slider { position: relative; height: 20px; }
.slider .track {
  position: absolute; top: 9px; left: 0; right: 0; height: 2px;
  background: #3a3a40;
  border-radius: 1px;
}
.slider .zero {
  position: absolute; top: 6px; width: 1px; height: 8px;
  background: #4a4a52;
}
.slider .delta {
  position: absolute; top: 8px; height: 4px;
  background: var(--human);
  border-radius: 2px;
  opacity: .85;
}
.slider .tick {
  position: absolute; top: 4px; width: 2px; height: 12px;
  background: var(--machine);
  border-radius: 1px;
}
.slider input[type=range] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  -webkit-appearance: none; appearance: none;
  background: transparent;
  margin: 0;
  cursor: ew-resize;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 6px; height: 16px;
  border-radius: 2px;
  background: #d5d5d0;
  border: 1px solid #0008;
  cursor: ew-resize;
}
.slider input[type=range]::-moz-range-thumb {
  width: 6px; height: 16px;
  border-radius: 2px;
  background: #d5d5d0;
  border: 1px solid #0008;
  cursor: ew-resize;
}
.prow.touched .slider input[type=range]::-webkit-slider-thumb { background: var(--human); }
.prow.touched .slider input[type=range]::-moz-range-thumb { background: var(--human); }

/* ── rail footer ─────────────────────────────────────────── */

.rail-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px 16px;
  background: var(--bg1);
}
.delta-summary {
  min-height: 18px;
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 10px;
  line-height: 1.7;
}
.delta-summary .d { color: var(--human); }
.delta-summary .none { color: var(--faint); }
.rail-actions { display: flex; gap: 10px; }
.rail-actions .btn-accept { flex: 1; padding: 12px; font-size: 14px; }
.rail-hint { margin-top: 10px; font-size: 11px; text-align: center; }

/* ── toast ───────────────────────────────────────────────── */

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 10px 16px;
  max-width: 80vw;
  z-index: 50;
}
.toast.info { border-left-color: var(--machine); }

/* ── responsive ──────────────────────────────────────────── */

@media (max-width: 1000px) {
  .editor-body { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .rail { border-left: none; border-top: 1px solid var(--line); }
  #stage-img { max-height: 58vh; }
  #params { max-height: 42vh; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .status-line { order: 3; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
