/* Light theme.
 *
 * Two constraints shaped this beyond taste. Labellers sit with it for hours, so
 * contrast is kept high but the background is off-white rather than pure white —
 * a full-white field next to a bright photo is fatiguing. And the surfaces
 * immediately around an image are deliberately neutral grey: a coloured or very
 * bright surround shifts how you judge scalp tone and hair density in the photo
 * next to it, which is the actual judgement being made here.
 */
:root {
  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --line:      #e2e6ec;
  --line-2:    #cbd3de;
  --text:      #16191f;
  --muted:     #64707f;
  --accent:    #1f6feb;
  --accent-sp: #e8f0fe;
  --ok:        #12805c;
  --ok-bg:     #e6f6f0;
  --warn:      #b25000;
  --warn-bg:   #fdf0e3;
  --bad:       #c3372b;
  --bad-bg:    #fdeceb;
  --canvas:    #e9ecf1;   /* neutral surround for the image being annotated */
  --shadow:    0 1px 2px rgba(16,25,40,.06), 0 4px 12px rgba(16,25,40,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  padding: 7px 13px; transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover:not(:disabled) { background: var(--surface-2); border-color: #aab5c4; }
button:active:not(:disabled) { background: #eef1f5; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(31,111,235,.25);
}
button.primary:hover:not(:disabled) { background: #1a60d0; border-color: #1a60d0; }
button.warn { background: var(--bad-bg); border-color: #f0c2bd; color: var(--bad); }

select, input, textarea {
  font: inherit; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; width: 100%;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sp);
}

/* ---- top bar: progress and backup health, always visible ---------------- */
header {
  position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line); padding: 10px 18px;
}
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-weight: 400; }
.metrics { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.metric { text-align: right; }
.metric b { font-size: 15px; font-variant-numeric: tabular-nums; }
.metric i { color: var(--muted); font-style: normal; font-size: 11.5px; display: block; }
.progress {
  height: 7px; background: #e6eaf0; border-radius: 99px; overflow: hidden;
  min-width: 190px; display: flex;
}
.progress > div { height: 100%; transition: width .4s ease; }
.p-done { background: var(--ok); }
.p-lab  { background: var(--accent); }
.pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: #eceff4; color: var(--muted); white-space: nowrap;
}
.pill.ok  { background: var(--ok-bg);  color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- layout ------------------------------------------------------------- */
main { padding: 18px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card.done    { border-color: #9fd9c4; }
.card.pending { border-color: #f0cfa4; }
.card img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  background: var(--canvas); display: block;
}
.card .body { padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: 9px; align-items: center; }
.row > label { flex: 0 0 82px; color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px; font-size: 12.5px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  cursor: pointer; user-select: none; transition: background .1s, border-color .1s;
}
.chip:hover { background: var(--surface-2); border-color: #aab5c4; }
.chip.on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.chip.off { opacity: .4; cursor: not-allowed; }
.muted { color: var(--muted); font-size: 12px; }
.warnmsg {
  background: var(--bad-bg); border: 1px solid #f2cbc6; color: var(--bad);
  padding: 9px 11px; border-radius: 9px; font-size: 13px;
}
.hint {
  background: var(--accent-sp); border: 1px solid #cfe0fb; color: #1d4ea8;
  padding: 9px 11px; border-radius: 9px; font-size: 12.5px;
}
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 11px; }

/* ---- polygon editor ----------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(16,25,40,.45);
  backdrop-filter: blur(2px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px;
}
.editor {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  width: min(1250px, 100%); max-height: 96vh; display: flex; overflow: hidden;
  box-shadow: 0 10px 40px rgba(16,25,40,.22);
}
/* Deliberately neutral grey, not white: a bright surround biases how the
   scalp tone inside the photo reads. */
.canvaswrap {
  position: relative; flex: 1; background: var(--canvas);
  display: flex; align-items: center; justify-content: center; min-width: 0;
}
.canvaswrap img { max-width: 100%; max-height: 92vh; display: block; }
.canvaswrap canvas { position: absolute; cursor: crosshair; }
.side {
  width: 335px; flex: 0 0 335px; border-left: 1px solid var(--line); padding: 16px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 13px;
  background: var(--surface);
}
.side h3 { margin: 0; font-size: 14px; }
.shape {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 6px 9px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px;
}
.kinds { display: flex; flex-direction: column; gap: 6px; }
.kindbtn { display: flex; align-items: center; gap: 9px; text-align: left; }
.kindbtn.on { border-color: var(--accent); background: var(--accent-sp); font-weight: 600; }

/* ---- region resolver rows ---------------------------------------------- */
.region { padding: 2px 0; }
.region .chip { font-size: 11.5px; }
