* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: #000; color: #ddd;
  font: 14px/1.4 system-ui, sans-serif;
}
body { display: flex; flex-direction: column; }

#topbar {
  position: relative; z-index: 101;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 14px; min-height: 42px;
  background: #111; border-bottom: 1px solid #2a2a2a;
  flex-wrap: wrap;
}
#topbar .left, #topbar .center, #topbar .right {
  display: flex; align-items: center; gap: 10px;
}
.pill {
  background: #1d1d1d; border: 1px solid #333; border-radius: 12px;
  padding: 3px 10px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pill.done { background: #143a16; border-color: #2e7d32; color: #b6f0b8; }
a.pill { color: #cdd6df; text-decoration: none; cursor: pointer; }
a.pill:hover { border-color: #1565c0; color: #fff; }


/* Hide topbar entirely on the sign-in page. */
#authGate:not(.hidden) ~ #topbar { display: none; }

/* On gate pages only show home + who; hide all labelling-specific topbar elements. */
body.gate-open #taskBar,
body.gate-open #progress,
body.gate-open #subject,
body.gate-open #labelTimer,
body.gate-open #labelledTag,
body.gate-open #adminLink,
body.gate-open #setExemplarBtn,
body.gate-open #browsePrevBtn,
body.gate-open #browseCounter,
body.gate-open #browseNextBtn,
body.gate-open #browseExitBtn,
body.gate-open #prevBtn,
body.gate-open #skipBtn,
body.gate-open #saveBtn { visibility: hidden; }

/* Floating admin gear shown above the gate overlays (z-index 100). */
.admin-float {
  position: fixed; top: 14px; right: 16px; z-index: 110;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: #1d1d1d; border: 1px solid #333; border-radius: 50%;
  color: #cdd6df; text-decoration: none; font-size: 18px; line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.admin-float:hover { border-color: #1565c0; color: #fff; }
/* Compact progress shown to non-admins in the top bar: bar + "N left". */
#progress:has(.mini-track) { display: inline-flex; align-items: center; gap: 8px; }
.mini-track {
  display: inline-block; width: 110px; height: 9px; vertical-align: middle;
  background: #0c0c0c; border-radius: 5px; overflow: hidden;
}
.mini-fill { display: block; height: 100%; background: #4a90d9; }
.mini-left { font-size: 13px; color: #b3c0cc; }
#who { cursor: pointer; }
#who:hover { background: #16335c; border-color: #1565c0; }

#taskBar { display: flex; flex-direction: column; gap: 1px; }
.task-head { display: flex; align-items: center; gap: 8px; }
#taskBarTitle {
  font-size: clamp(22px, 1.9vw, 30px); font-weight: 700; letter-spacing: .01em; color: #fff;
}
.task-context-line {
  font-size: clamp(14px, 1.3vw, 18px); color: #b3c0cc;
  letter-spacing: .04em; text-transform: uppercase; font-weight: 600;
}

/* Task colour modes -- pastel red = disease task, pastel green = normal task.
   Colour + a left accent bar + a tinted header border make the mode obvious. */
#taskBar { border-left: 3px solid transparent; padding-left: 10px; }
body.mode-abnormal #taskBar { border-left-color: #ff7a7a; }
body.mode-normal   #taskBar { border-left-color: #5fd08a; }
body.mode-abnormal #taskBarTitle { color: #ffb0b0; }
body.mode-normal   #taskBarTitle { color: #9fe6bd; }
body.mode-abnormal .task-context-line { color: #e0a3a3; }
body.mode-normal   .task-context-line { color: #93c7ab; }
body.mode-abnormal #topbar { border-bottom-color: #5a2a2a; }
body.mode-normal   #topbar { border-bottom-color: #2a5a3c; }
/* Ambient surround: faint mode tint on the leftover margin, plus a thin
   mode-coloured frame around the image block. Pixels stay neutral. */
body.mode-abnormal #gridWrap { background: #150d0d; }
body.mode-normal   #gridWrap { background: #0d150f; }
body.mode-abnormal #grid { box-shadow: 0 0 0 2px #3a1d1d; }
body.mode-normal   #grid { box-shadow: 0 0 0 2px #1b3a2a; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  background: none; border: 1px solid #3a3a3a; color: #cdd9e2;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.iconbtn:hover { background: #16335c; border-color: #1565c0; }
#homeBtn { font-size: 18px; }
.hidden { display: none !important; }

select, button {
  background: #1d1d1d; color: #eee; border: 1px solid #3a3a3a;
  border-radius: 6px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}
button:hover { background: #2a2a2a; }
button.primary { background: #1565c0; border-color: #1565c0; color: #fff; }
button.primary:hover { background: #1976d2; }
button.secondary { background: transparent; border-color: #444; color: #9aa6b2; }
button.secondary:hover { border-color: #8fbdf0; color: #cdd6df; }

.dx-label { color: #999; }
.dx.active.normal { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.dx.active.chd { background: #c62828; border-color: #c62828; color: #fff; }
/* diagnosis buttons are display-only (fixed ground truth) */
.dx { cursor: default; }
.dx:disabled { opacity: 1; }
.dx:disabled:not(.active) { opacity: .45; }

#hint { padding: 5px 14px; color: #888; font-size: 12px; background:#0a0a0a; border-bottom:1px solid #1a1a1a;}

#gridWrap { flex: 1; position: relative; display: flex; min-height: 0; overflow: hidden; }
#grid {
  /* Centred so the aspect-locked block of cells sits in the middle; any
     leftover space (unavoidable when preserving aspect ratio without cropping)
     collapses to a single outer margin instead of bars around every image. */
  margin: auto; display: grid; gap: 0; padding: 0;
  max-width: 100%; max-height: 100%;
}
#lockOverlay {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
}
.lock-card {
  background: #1d1d1d; border: 1px solid #444; border-radius: 10px;
  padding: 22px 30px; font-size: 18px; color: #ffd27f;
}

/* name gate */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: #000; display: flex; align-items: center; justify-content: center;
}
.gate-box {
  background: #111; border: 1px solid #2a2a2a; border-radius: 12px;
  padding: 32px 36px; width: min(90vw, 360px);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.gate-box h1 { margin: 0; font-size: 20px; }
.gate-box p { margin: 0; color: #999; }
.gate-empty { margin-top: 8px; font-size: 15px; }
.gate-box.wide { width: min(92vw, 760px); }

.choice-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 26px 18px; border-radius: 12px; cursor: pointer;
  background: #1d1d1d; border: 1px solid #3a3a3a; color: #eee;
}
.choice:hover { background: #16335c; border-color: #1565c0; }
.choice .code { font-size: 26px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.choice .full { font-size: 16px; color: #9aa6b2; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.choice.choice-hidden { opacity: 0.5; border-style: dashed; }
.show-all-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: #6b7280; cursor: pointer; user-select: none; }
.show-all-row input { cursor: pointer; }
.choice .prog { width: 100%; font-size: 12px; color: #6ea8fe; font-variant-numeric: tabular-nums; }

/* Independent, colour-coded progress per phase (on the view-selection screen) */
.pbar { display: block; width: 100%; margin-top: 10px; }
.pbar-label { display: block; font-size: 13px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.pbar-track { display: block; height: 10px; background: #0c0c0c; border-radius: 5px; overflow: hidden; }
.pbar-fill { display: block; height: 100%; }
.pbar-abnormal .pbar-label { color: #ff9d9d; }
.pbar-abnormal .pbar-fill { background: #c0504f; }
.pbar-normal .pbar-label { color: #8fe3b0; }
.pbar-normal .pbar-fill { background: #2e7d52; }
.pbar-overall .pbar-label { color: #cdd6e0; font-weight: 600; }
.pbar-overall .pbar-fill { background: #4a90d9; }

/* Disease-wide joint progress: larger and set apart above the view choices. */
#diseaseProgress { margin: 6px 0 20px; }
#diseaseProgress .pbar-label { font-size: 16px; }
#diseaseProgress .pbar-track { height: 14px; border-radius: 7px; }
.linkbtn {
  background: none; border: none; color: #6ea8fe; cursor: pointer;
  font-size: 13px; padding: 4px; align-self: center;
}
.linkbtn:hover { text-decoration: underline; background: none; }

/* Task / phase priming screen */
.task-num {
  color: #6ea8fe; font-size: clamp(18px, 1.8vw, 26px); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.task-context { margin: 0; color: #9aa6b2; font-size: clamp(14px, 1.1vw, 17px); }
.task-headline {
  margin: 0 0 12px; font-weight: 600; color: #fff;
  font-size: clamp(17px, 1.6vw, 23px);
}
body.mode-abnormal .task-headline { color: #ffb0b0; }
body.mode-normal   .task-headline { color: #9fe6bd; }

/* Whole task card themed by mode: red = disease task, green = normal task. */
body.mode-abnormal #taskGate .gate-box {
  background: linear-gradient(#1f1010, #160c0c); border-color: #6a3030;
}
body.mode-normal #taskGate .gate-box {
  background: linear-gradient(#101f14, #0c160f); border-color: #2f6a45;
}
body.mode-abnormal #taskNum { color: #ff8a8a; }
body.mode-normal   #taskNum { color: #7fd6a0; }
body.mode-abnormal .task-detail { background: #1d1212; border-color: #5a2a2a; }
body.mode-normal   .task-detail { background: #121d16; border-color: #2a5a3c; }

/* Buttons coloured by destination: Skip -> green (normal task); on the normal
   task, Back -> red (abnormal task). Abnormal-task Back stays neutral (-> views). */
#skipToNormal { color: #5fd08a; }
#skipToNormal:hover { color: #7ee0a4; }
body.mode-normal #taskBackBtn { color: #ff8a8a; }
body.mode-normal #taskBackBtn:hover { color: #ffb0b0; }
/* Task screen: header (number/title/view) stays centred; the box below is
   left-aligned with the headline as its title. */
.task-gate-body {
  display: flex; flex-direction: row; align-items: stretch; gap: 16px;
}
.task-detail {
  background: #161616; border: 1px solid #2a2a2a; border-radius: 10px;
  padding: 16px 18px; text-align: left; flex: 1; min-width: 0;
}
.task-instructions {
  text-align: left; margin: 0; padding-left: 22px;
  display: flex; flex-direction: column; gap: 10px;
  font-size: clamp(15px, 1.25vw, 19px); line-height: 1.45;
}
.task-instructions li { color: #e8edf2; }

/* Admin instruction editor */
.task-edit { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.edit-row { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #9aa6b2; }
.edit-row input, .edit-row textarea {
  background: #1d1d1d; color: #eee; border: 1px solid #3a3a3a;
  border-radius: 6px; padding: 9px 11px; font-size: 15px; font-family: inherit;
}
.edit-row textarea { resize: vertical; }
.task-actions {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; margin-top: 4px;
}
.ta-left { justify-self: start; display: flex; align-items: center; gap: 10px; }
.ta-center { justify-self: center; }
.ta-right { justify-self: end; display: flex; align-items: center; gap: 10px; }
/* Back button bottom-left on the view screen too (same place as the task screen) */
.gate-actions { width: 100%; display: flex; justify-content: flex-start; }
.gate-box input {
  background: #1d1d1d; color: #eee; border: 1px solid #3a3a3a;
  border-radius: 6px; padding: 10px 12px; font-size: 15px;
}

/* Larger, polished, viewport-responsive name/login screen.
   clamp() scales it with screen size so it looks right on a laptop and on a
   hi-res (e.g. 2560x1600) display without being fixed-small or absurdly big. */
#authForm {
  width: clamp(360px, 26vw, 520px);
  padding: clamp(36px, 3vw, 56px) clamp(40px, 3.4vw, 64px);
  gap: clamp(14px, 1.2vw, 22px);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#authForm .brand-icon { font-size: clamp(44px, 4vw, 68px); line-height: 1; }
#authForm h1 { font-size: clamp(26px, 2.1vw, 40px); letter-spacing: .01em; }
#authForm p { font-size: clamp(14px, 1.1vw, 18px); color: #9aa6b2; }
#authForm input {
  font-size: clamp(16px, 1.3vw, 20px); padding: clamp(12px, 1vw, 16px) 16px;
  text-align: center; border-radius: 8px;
}
#authForm .primary {
  font-size: clamp(15px, 1.2vw, 19px); padding: clamp(11px, 0.9vw, 15px) 16px;
  border-radius: 8px;
}
#authForm input { text-align: left; }
.auth-error { min-height: 1.2em; color: #ff9d9d; font-size: 14px; margin: 0; }
.cell {
  position: relative; background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 0;
}
.cell img {
  width: 100%; height: 100%;
  object-fit: contain; display: block; user-select: none; -webkit-user-drag: none;
}
.cell canvas {
  position: absolute; left: 0; top: 0; cursor: crosshair;
}
.fnum {
  position: absolute; top: 2px; left: 4px; font-size: 10px; color: #555;
  pointer-events: none;
}

/* Exemplar selection mode */
#gridWrap.exemplar-selecting .cell canvas { cursor: crosshair; }
#gridWrap.exemplar-selecting .cell:hover canvas { outline: 3px solid #f59e0b; outline-offset: -3px; }
#gridWrap.exemplar-selecting { outline: 2px dashed #f59e0b; }

/* Exemplar display on task gate — sits outside/right of the detail card */
.task-exemplar { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; gap: 6px; }
.exemplar-label { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .08em; }
.exemplar-frame { position: relative; display: inline-block; border-radius: 6px; overflow: hidden; border: 1px solid #333; }
.exemplar-frame img { display: block; max-width: 220px; max-height: 220px; object-fit: contain; }
.exemplar-frame canvas { position: absolute; top: 0; left: 0; pointer-events: none; }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #c62828; color: #fff; padding: 8px 16px; border-radius: 6px;
  z-index: 150; box-shadow: 0 2px 10px rgba(0,0,0,.5);
}

#labelTimer { font-family: monospace; }
#labelTimer .total { color: #fff; font-weight: 600; }

/* ===================== BATCH ADMIN ===================== */
body.admin { display: block; overflow: auto; }
#adminApp { max-width: 980px; margin: 0 auto; padding: 18px 20px 60px; }
.admin-bar { display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #1a1a1a; padding-bottom: 12px; margin-bottom: 18px; }
.admin-bar h1 { font-size: 20px; margin: 0; }
.admin-bar-right { display: flex; align-items: center; gap: 14px; }
.who { color: #9aa6b2; font-size: 13px; }

.admin-card { background: #0c0c0c; border: 1px solid #1f1f1f; border-radius: 8px;
  padding: 16px 18px; margin-bottom: 18px; }
.admin-card h2 { font-size: 15px; margin: 0 0 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.dirty-note { color: #d8b454; font-size: 12px; font-weight: 600; }
button.primary.dirty { background: #b45309; border-color: #b45309; }
button.primary.dirty:hover { background: #c2620f; }
.hint { color: #888; font-size: 12.5px; margin: 0 0 12px; line-height: 1.5; }
.hint code { background: #1a1a1a; padding: 1px 5px; border-radius: 4px; color: #cdd6df; }
.chip-link { color: #cdd6df; }

.completed-tasks-panel { margin-top: 14px; border-top: 1px solid #1f1f1f; padding-top: 10px; }
.completed-tasks-panel summary { cursor: pointer; color: #9aa6b2; font-size: 13px; font-weight: 600; }
.completed-tasks-panel .hint { margin-top: 8px; }
.completed-list .batch-row { opacity: .7; }

.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-row input[type=file] { flex: 1 1 240px; color: #cdd6df; font-size: 13px; }
.upload-row input[type=text] { background: #1d1d1d; color: #eee; border: 1px solid #3a3a3a;
  border-radius: 5px; padding: 7px 10px; font-size: 13px; flex: 0 1 220px; }
.upload-status { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.upload-status .bar-track { flex: 1; }
.upload-status span { color: #9aa6b2; font-size: 12.5px; white-space: nowrap; }

.bar-track { height: 8px; background: #1a1a1a; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: #1565c0; width: 0; transition: width .2s; }

.batch-list { list-style: none; margin: 0; padding: 0; }
.batch-row { display: flex; align-items: center; gap: 12px; background: #131313;
  border: 1px solid #262626; border-radius: 7px; padding: 10px 12px; }
.batch-row.dragging { opacity: .4; }
.batch-row.disabled { opacity: .55; }
.drag-handle { cursor: grab; color: #666; font-size: 16px; user-select: none; }
.tier-badge { font-size: 11px; color: #9aa6b2; background: #1d1d1d; border: 1px solid #333;
  border-radius: 4px; padding: 2px 6px; min-width: 30px; text-align: center; }
.batch-main { flex: 1 1 auto; min-width: 0; }
.batch-title { font-size: 14px; }
.batch-id { color: #6b7682; font-size: 11.5px; margin-left: 6px; }
.batch-meta { margin-top: 2px; display: flex; gap: 10px; font-size: 11px; color: #555; font-family: monospace; }
.batch-chips { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 10.5px; background: #16314f; color: #bcd6f3; border-radius: 4px; padding: 1px 6px; }
.chip.muted { background: #1d1d1d; color: #8a929b; }
.ds-field { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; color: #8a929b; }
.ds-input { width: 64px; background: #1d1d1d; color: #cdd6df; border: 1px solid #333;
  border-radius: 4px; padding: 1px 5px; font-size: 11px; }
.ds-input:focus { border-color: #1565c0; outline: none; }
.batch-prog { width: 130px; flex: 0 0 auto; }
.batch-prog .prog-text { display: block; text-align: right; color: #8a929b; font-size: 11px; margin-top: 3px; }

.status-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 4px; padding: 2px 7px; }
.status-active { background: #14361f; color: #7fdca0; }
.status-queued { background: #16314f; color: #8fbdf0; }
.status-complete { background: #232a31; color: #9aa6b2; }
.status-disabled, .status-hidden { background: #2a2a2a; color: #888; }
.status-empty { background: #3a2a12; color: #d8a054; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #3a3a3a; border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: #1565c0; }
.switch input:checked + span::before { transform: translateX(16px); }
.del-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 4px; opacity: .7; }
.del-btn:hover { opacity: 1; }

.email-cols { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 14px; }
.email-cols > div { flex: 1 1 260px; min-width: 220px; }
.email-cols h3, #pendingWrap h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  color: #9aa6b2; margin: 0 0 8px; }
.email-add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.email-add-row input { flex: 1; background: #1d1d1d; color: #eee; border: 1px solid #3a3a3a;
  border-radius: 5px; padding: 6px 9px; font-size: 13px; }
.email-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.email-row { display: flex; align-items: center; gap: 10px; background: #131313;
  border: 1px solid #262626; border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.email-row span:first-child { flex: 1; }
.email-row .hint { margin: 0; }
#pendingWrap { margin-bottom: 14px; }
#pendingList .email-row button.secondary { font-size: 11.5px; padding: 3px 8px; }

.chain-gap { list-style: none; display: flex; justify-content: center; padding: 3px 0; }
.chain-btn { background: #161616; border: 1px dashed #333; color: #777; border-radius: 12px;
  font-size: 11px; padding: 2px 12px; cursor: pointer; }
.chain-gap.chained .chain-btn { border-style: solid; border-color: #1565c0; color: #74b9e0; background: #0e1f30; }

.batch-row.expandable { flex-wrap: wrap; }
.browse-exemplar-link {
  background: none; border: 1px solid #2a2a2a; border-radius: 5px;
  padding: 4px 7px; font-size: 14px; cursor: pointer; text-decoration: none;
  color: #444; opacity: 0.5;
}
.browse-exemplar-link.exemplar-set { opacity: 1; }
.browse-exemplar-chd.exemplar-set   { color: #ff8a8a; border-color: #5a2a2a; }
.browse-exemplar-normal.exemplar-set { color: #7fd6a0; border-color: #2a5a3c; }
.browse-exemplar-chd:hover   { opacity: 1; color: #ff8a8a; border-color: #5a2a2a; }
.browse-exemplar-normal:hover { opacity: 1; color: #7fd6a0; border-color: #2a5a3c; }
.expand-btn { background: none; border: 1px solid #333; color: #8a929b; border-radius: 5px;
  font-size: 11px; padding: 2px 8px; cursor: pointer; white-space: nowrap; }
.expand-btn:hover { border-color: #555; color: #cdd6df; }
.stream-sub-panel { width: 100%; margin-top: 10px; padding-top: 10px; border-top: 1px solid #222; }
.sub-head { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 8px; }

.disk-scan-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.disk-scan-row input[type="text"] { flex: 1; min-width: 180px; }
.disk-n-label { font-size: 12px; color: #9aa6b2; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.disk-n-input { width: 52px; text-align: center; }
.disk-summary { margin-bottom: 12px; }
.disk-df { display: flex; gap: 24px; font-size: 13px; color: #9aa6b2; margin-bottom: 6px; }
.disk-df b { color: #cdd6df; }
.disk-bar { width: 100%; max-width: 400px; }
.disk-tree { list-style: none; margin: 0; padding: 0; }
.disk-entry { border-bottom: 1px solid #1a1a1a; }
.disk-row { display: flex; align-items: center; gap: 10px; padding: 5px 6px; }
.disk-row:hover { background: #161616; }
.disk-name { flex: 1; font-size: 13px; color: #cdd6df; font-family: monospace; }
.disk-dir { color: #8fbdf0; }
.disk-size { font-size: 12px; color: #9aa6b2; min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }
.disk-actions { min-width: 28px; }
.disk-children { padding-left: 20px; border-left: 1px solid #222; }
.disk-file { color: #9aa6b2; }
.disk-more { font-size: 11px; color: #555; padding: 3px 6px; font-style: italic; }
.disk-loading { font-size: 12px; color: #666; padding: 6px; display: block; }
.disk-error { font-size: 12px; color: #e57373; padding: 6px; display: block; }

/* Filesystem browser */
.disk-browse-pane { border: 1px solid #222; border-radius: 6px; margin-bottom: 14px; overflow: hidden; }
.disk-ls-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.ls-children { list-style: none; margin: 0; padding: 0; }
.ls-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid #111; }
.ls-row:hover { background: #161616; }
.ls-arrow { color: #555; font-size: 10px; cursor: pointer; min-width: 14px; text-align: center; user-select: none; }
.ls-dir { flex: 1; background: none; border: none; color: #8fbdf0; cursor: pointer; text-align: left; font-family: monospace; font-size: 13px; padding: 0; }
.ls-dir:hover { color: #cdd6df; text-decoration: underline; }
.ls-add { background: none; border: 1px solid #333; border-radius: 4px; color: #9aa6b2; cursor: pointer; font-size: 11px; padding: 2px 7px; white-space: nowrap; margin-right: 8px; }
.ls-add:hover { border-color: #8fbdf0; color: #cdd6df; }
.ls-file-row { border-bottom: none; }
.ls-file { font-family: monospace; font-size: 12px; color: #666; }
.ls-more { font-size: 11px; color: #444; font-style: italic; }
.ls-loading, .ls-empty, .ls-error { font-size: 12px; color: #666; display: block; padding: 4px 0; }
.ls-error { color: #e57373; }

/* Disease-view grid */
.dv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dv-table th { padding: 6px 14px; color: #9aa6b2; font-weight: 600; border-bottom: 1px solid #222; text-align: center; }
.dv-table th:first-child { text-align: left; }
.dv-table td { padding: 6px 14px; border-bottom: 1px solid #111; text-align: center; }
.dv-table td:first-child { text-align: left; color: #cdd6df; font-family: monospace; font-weight: 600; }
.dv-table tr:hover td { background: #161616; }
.dv-table input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: #8fbdf0; }

/* Labeller stats */
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th { text-align: left; padding: 6px 12px; color: #9aa6b2; font-weight: 600; border-bottom: 1px solid #222; }
.stats-table td { padding: 7px 12px; border-bottom: 1px solid #111; }
.stats-table tr:hover td { background: #161616; }
.stats-email { color: #cdd6df; font-family: monospace; }
.stats-num { color: #8fbdf0; font-variant-numeric: tabular-nums; }
.stats-date { color: #9aa6b2; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.status-green { background: #3ecf5f; }
.status-dot.status-amber { background: #d9a441; }
.status-dot.status-grey { background: #555; }

/* Task admin panel */
.task-create-row { display: flex; gap: 10px; margin-bottom: 14px; }
.task-create-row input { flex: 1; background: #1a1a1a; border: 1px solid #2a2a2a; color: #ddd; padding: 7px 10px; border-radius: 4px; font-size: 13px; }
.incl-list { list-style: none; padding: 0; margin: 6px 0; }
.incl-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; background: #161616; border-radius: 4px; margin-bottom: 4px; font-size: 13px; font-family: monospace; }
.task-inclusions h4 { margin: 10px 0 4px; font-size: 12px; color: #9aa6b2; font-weight: 600; }
.task-panel-save { margin-right: auto; }
.incl-add-section { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.incl-precursor label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #9aa6b2; font-weight: 600; }
.incl-precursor select { background: #1a1a1a; border: 1px solid #2a2a2a; color: #ddd; padding: 6px 8px; border-radius: 4px; font-size: 12px; }
.incl-modes { display: flex; flex-direction: column; gap: 6px; padding-left: 8px; border-left: 2px solid #2a2a2a; }
.incl-mode-row { display: flex; gap: 8px; align-items: center; }
.incl-mode-row select, .incl-mode-row input { flex: 1; background: #1a1a1a; border: 1px solid #2a2a2a; color: #ddd; padding: 6px 8px; border-radius: 4px; font-size: 12px; }
.incl-ft-inp::placeholder { color: #555; }
.incl-ft-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; padding: 8px; background: #111; border: 1px solid #2a2a2a; border-radius: 4px; }
.ft-chip { font-family: monospace; font-size: 12px; padding: 3px 8px; border-radius: 3px; border: 1px solid transparent; cursor: pointer; transition: opacity 0.1s; }
.ft-chip-on       { background: #1a3a1a; border-color: #3a7a3a; color: #7dcc7d; }
.ft-chip-off      { background: #1a1a1a; border-color: #2a2a2a; color: #555; }
.ft-chip-included { background: #1e1e2e; border-color: #5a6aaa; color: #c8d0f0; cursor: default; }
.ft-chip:not(.ft-chip-included):hover { opacity: 0.75; }
.ft-hint { font-size: 12px; color: #555; font-style: italic; }
.ft-error { color: #c0392b; }

/* Grid-size control: only while labelling a grid (hidden behind any gate, and while browsing). */
#gridSize select { font: inherit; }
body:has(.gate:not(.hidden)) #gridSize,
body.browse-mode #gridSize { display: none; }

/* Biometry task: class buttons under every frame */
.cell .cls-btns {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; gap: 2px; padding: 3px; background: rgba(0,0,0,.55);
}
.cell .cls-btns button {
  flex: 1; padding: 4px 0; font-size: 12px; font-weight: 700; cursor: pointer;
  background: #1c1c1c; color: var(--cc); border: 1px solid var(--cc); border-radius: 4px;
}
.cell .cls-btns button:hover { background: #2a2a2a; }
.cell .cls-btns button.on { background: var(--cc); color: #111; }

/* Palette bar (classification tasks with many classes) */
#classBar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px; background: #0d0d0d; border-bottom: 1px solid #222; }
#classBar.hidden { display: none; }
#classBar .cb { padding: 4px 8px; font-size: 12px; cursor: pointer; background: #1a1a1a; color: var(--cc);
  border: 1px solid var(--cc); border-radius: 4px; }
#classBar .cb kbd { opacity: .7; font-size: 10px; margin-right: 3px; }
#classBar .cb.on { background: var(--cc); color: #111; font-weight: 700; }
#classBar .cb.cb-sugg { outline: 2px dashed #fff; outline-offset: 1px; }
#classBar .cb.cb-sugg i { font-weight: 400; font-size: 11px; opacity: .8; }

/* Single-image mode: no Save button, no grid-size control, big image */
body.single-mode #saveBtn, body.single-mode #gridSize { display: none; }
#classBar .cb-count { align-self: center; margin-right: 8px; color: #bbb; font-size: 13px; }
#classBar .cb-back { margin-left: auto; }

/* Many classes (B-mode): one vertical list down the left side, head at the top, foot at the bottom */
body.class-list #classBar { position: fixed; left: 0; bottom: 0; top: var(--topbar-h, 48px); width: 250px; z-index: 80;
  flex-direction: column; flex-wrap: nowrap; gap: 3px; overflow-y: auto; border-bottom: 0; border-right: 1px solid #222; }
body.class-list #classBar .cb { text-align: left; padding: 6px 8px; font-size: 13px; flex: none; }
body.class-list #classBar .cb kbd { display: inline-block; min-width: 14px; font-size: 11px; }
body.class-list #classBar .cb-count { margin: 0 0 2px; }
body.class-list #classBar .cb-cap { color: #777; font-size: 11px; margin: 0 0 2px; }
body.class-list #classBar .cb-none { margin-top: 6px; }
body.class-list #classBar .cb-cap:not(:first-child) { margin-top: 8px; }
#classBar .cb-mode { border-style: dashed; }
body.class-list #classBar .cb-back { margin-left: 0; margin-top: auto; }
body.class-list #hint, body.class-list #gridWrap, body.class-list #exampleStrip { margin-left: 250px; }

/* Task chooser: stage headings */
.stage-head { grid-column: 1 / -1; text-align: left; margin-top: 10px; padding-bottom: 4px; border-bottom: 1px solid #2a2a2a; }
.stage-head:first-child { margin-top: 0; }
.stage-head b { font-size: 15px; margin-right: 10px; }
.stage-head span { color: #888; font-size: 13px; }

/* Compact task chooser: more cards per row, scrolls instead of overflowing the screen */
#diseaseGate .gate-box.wide { width: min(96vw, 1000px); max-height: 92vh; overflow-y: auto; padding: 18px 22px; gap: 10px; }
#diseaseGate .gate-box h1 { font-size: 17px; }
#diseaseGate .choice-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
#diseaseGate .choice { padding: 9px 11px; gap: 2px; border-radius: 8px; align-items: flex-start; text-align: left; }
#diseaseGate .choice .code { font-size: 14px; letter-spacing: 0; text-transform: none; line-height: 1.2; }
#diseaseGate .choice .full { font-size: 11px; letter-spacing: 0; text-transform: none; }
#diseaseGate .pbar { margin-top: 4px; }
#diseaseGate .pbar-label { font-size: 11px; margin-bottom: 2px; }
#diseaseGate .pbar-track { height: 5px; border-radius: 3px; }
#diseaseGate .stage-head { margin-top: 6px; }
#diseaseGate .stage-head b { font-size: 13px; }
#diseaseGate .stage-head span { font-size: 11px; }

/* Reference examples (Good / Acceptable / Poor) on standard-plane labelling pages */
#exampleStrip { display: flex; align-items: center; gap: 10px; padding: 5px 14px; background: #0a0a0a; border-bottom: 1px solid #1a1a1a; }
#exampleStrip.hidden { display: none; }
#exampleStrip .ex-title { color: #888; font-size: 12px; margin-right: 4px; }
#exampleStrip .ex-card { position: relative; display: flex; align-items: flex-end; }
#exampleStrip .ex-card img { height: clamp(56px, 11vh, 110px); width: auto; display: block; border-radius: 4px; cursor: zoom-in; border: 1px solid #333; }
#exampleStrip .ex-none { height: clamp(56px, 11vh, 110px); aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 4px; font-size: 11px; color: #666; border: 1px dashed #444; border-radius: 4px; }
#exampleStrip .ex-tag { position: absolute; left: 4px; bottom: 4px; padding: 1px 7px; border-radius: 3px; color: #111; font-size: 11px; font-weight: 700; }
#exampleStrip .ex-clear { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; line-height: 14px; padding: 0;
  border-radius: 9px; border: 0; background: rgba(0,0,0,.65); color: #ddd; cursor: pointer; font-size: 13px; }
#lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
#lightbox.hidden { display: none; }
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }
body.gate-open #exampleStrip { display: none; }

/* Stage 1: examples side panel (compare the image on screen with a reference per label) */
#examplePanel { position: fixed; right: 0; bottom: 0; top: var(--topbar-h, 48px); width: 300px; z-index: 90;
  overflow-y: auto; background: #0d0d0d; border-left: 1px solid #2a2a2a; padding: 8px 10px; }
#examplePanel.hidden { display: none; }
body.panel-open #gridWrap { margin-right: 300px; }
#examplePanel .ep-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 6px; }
#examplePanel .ep-close { background: none; border: 0; color: #aaa; font-size: 18px; cursor: pointer; }
#examplePanel section { margin-bottom: 10px; }
#examplePanel .ep-class { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cc); font-weight: 600; margin-bottom: 4px; }
#examplePanel .ep-class kbd { opacity: .7; font-size: 10px; }
#examplePanel .ep-add { margin-left: auto; padding: 0 6px; cursor: pointer; background: #1a1a1a; color: #ddd; border: 1px solid #444; border-radius: 4px; }
#examplePanel .ep-row { display: flex; flex-wrap: wrap; gap: 4px; }
#examplePanel .ep-img { position: relative; }
#examplePanel .ep-img img { width: 134px; height: 100px; object-fit: contain; background: #000; border: 1px solid #333; border-radius: 4px; cursor: zoom-in; display: block; }
#examplePanel .ep-img button { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; line-height: 14px; padding: 0;
  border-radius: 9px; border: 0; background: rgba(0,0,0,.7); color: #ddd; cursor: pointer; font-size: 13px; }
#examplePanel .ep-none { font-size: 11px; color: #666; padding: 8px; border: 1px dashed #444; border-radius: 4px; }
body.panel-open #classBar, body.panel-open #hint { margin-right: 300px; }
#examplePanel .ep-img img { width: 278px; height: 190px; }

/* Examples button + panel: light red */
#examplesBtn { background: #f4a6a6; color: #3a1010; border: 1px solid #e58a8a; font-weight: 600; }
#examplesBtn:hover { background: #f8bcbc; }
#examplesBtn.dirty { background: #e07f7f; color: #fff; border-color: #c96464; }   /* panel open */
#examplePanel { background: #1c1212; border-left: 2px solid #f4a6a6; }
#examplePanel .ep-head { color: #f4a6a6; border-bottom: 1px solid #5a3030; padding-bottom: 6px; }
#examplePanel .ep-close { color: #f4a6a6; }
#examplePanel .ep-img img { border-color: #6b3b3b; }
#examplePanel .ep-none { border-color: #6b3b3b; color: #b58a8a; }
#examplePanel .ep-add { background: #f4a6a6; color: #3a1010; border-color: #e58a8a; }

/* Task start panel: instruction hint + "I have read the instructions" check-off */
.task-instructions li.instr-hint { color: #f4a6a6; list-style: none; margin-top: 6px; }
.ack-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 2px; font-size: 14px; cursor: pointer; user-select: none; }
.ack-row.done { color: #7bd88f; cursor: default; }
.ack-row input { width: 18px; height: 18px; cursor: inherit; }
#taskStart:disabled { opacity: .45; cursor: not-allowed; }

/* Task start panel: scrolls on short screens; read-confirmation + Start stay pinned at the bottom */
#taskGate .gate-box { max-height: calc(100vh - 96px); overflow-y: auto; margin-top: 48px; }
#taskGate .ack-row { position: sticky; bottom: 44px; z-index: 2; margin: 8px 0 0; padding: 9px 14px;
  background: #2a1717; border: 1px solid #f4a6a6; border-radius: 8px; font-size: 15px; font-weight: 600; }
#taskGate .ack-row.done { background: #14261a; border-color: #4fae6a; }
#taskGate .task-actions { position: sticky; bottom: 0; z-index: 2; padding: 8px 0 2px; background: inherit; background-color: #160c0c; }

/* Stage 2: examples strip in the same light red as the stage-1 examples panel */
#exampleStrip { background: #1c1212; border-bottom: 2px solid #f4a6a6; }
#exampleStrip .ex-title { color: #f4a6a6; font-weight: 700; }
#exampleStrip .ex-card img { border-color: #6b3b3b; }
#exampleStrip .ex-none { border-color: #6b3b3b; color: #b58a8a; }

/* Help: opens on hover, stays open once clicked */
#helpWrap { display: inline-block; position: relative; }
#helpBtn.dirty { background: #3a3a3a; color: #fff; }
#helpPanel { position: fixed; right: 12px; top: var(--topbar-h, 48px); width: 420px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--topbar-h, 48px) - 16px); overflow-y: auto; z-index: 120; padding: 6px 16px 12px;
  background: #1a1a1a; color: #ddd; border: 1px solid #444; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.6);
  font-size: 13px; line-height: 1.45; text-align: left; }
#helpPanel.hidden { display: none; }
#helpPanel h3 { margin: 12px 0 4px; font-size: 13px; color: #fff; }
#helpPanel p, #helpPanel ul, #helpPanel ol { margin: 0 0 4px; }
#helpPanel ul, #helpPanel ol { padding-left: 20px; }
#helpPanel li { margin: 2px 0; }
#helpPanel details { margin: 6px 0; border: 1px solid #333; border-radius: 4px; padding: 4px 8px; }
#helpPanel summary { cursor: pointer; font-weight: 600; color: #fff; }
#helpPanel details[open] { background: #202020; }
#helpPanel kbd { background: #333; border-radius: 3px; padding: 0 4px; }
