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

#toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #26292e; border-bottom: 1px solid #000; flex-wrap: wrap;
}
.sep { width: 1px; height: 22px; background: #444; margin: 0 4px; }

.btn, .tool {
  padding: 6px 12px; border: 1px solid #555; border-radius: 6px;
  background: #33373d; color: #e8e8e8; cursor: pointer; font-size: 13px;
}
.btn:hover, .tool:hover { background: #3d4249; }
.btn:disabled, .tool:disabled {
  background: #2b2e33; border-color: #3a3a3a; color: #777; cursor: not-allowed;
}
.tool:disabled:hover { background: #2b2e33; }
.btn.primary { background: #2f6fd8; border-color: #2f6fd8; }
.btn.primary:disabled { background: #3a3f45; border-color: #555; color: #888; cursor: not-allowed; }
.tool.active { background: #2f6fd8; border-color: #2f6fd8; }
#tool-positive.active { background: #1f9d55; border-color: #1f9d55; }
#tool-negative.active { background: #d63b3b; border-color: #d63b3b; }

.brush { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #bbb; }
#status { color: #b9c0c8; font-size: 13px; }

#progress {
  width: 140px; height: 10px; vertical-align: middle;
  accent-color: #2f6fd8; /* modern browsers colour the bar with this */
}
#progress[hidden] { display: none; }

#content { flex: 1; display: flex; min-height: 0; }
#viewer { flex: 1; position: relative; background: #0e0f11; }

/* --- specimen sidebar --------------------------------------------------- */
#sidebar {
  width: 300px; flex: none; overflow-y: auto;
  background: #202226; border-left: 1px solid #000; padding: 8px;
}
#sidebar[hidden] { display: none; }
#sidebar-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#sidebar-head strong { font-size: 13px; }
#specimen-summary { font-size: 11px; color: #b9c0c8; margin-bottom: 8px; }
#sidebar-head .btn { padding: 4px 10px; font-size: 12px; }
#sidebar-head .btn:disabled { opacity: 0.45; }
#reframe-btn { margin-left: auto; }
#refine-badge {
  background: #2f6fd8; border-radius: 8px; padding: 0 5px;
  font-size: 11px; margin-left: 4px;
}
#refine-badge[hidden] { display: none; }
#specimen-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.spec {
  position: relative; cursor: pointer; background: #17181b;
  border: 3px solid #3a3f47; border-radius: 5px; overflow: hidden;
  transition: transform .08s;
}
.spec:hover { transform: scale(1.015); }
.spec img { width: 100%; display: block; transition: filter .1s; }
.spec .n {
  position: absolute; top: 3px; left: 5px; font-size: 11px; font-weight: 600;
  color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; z-index: 3;
}

/* the ✓ / ✕ action buttons */
.spec .acts { position: absolute; top: 3px; right: 3px; display: flex; gap: 3px; z-index: 3; }
.spec .acts button {
  width: 21px; height: 21px; line-height: 19px; padding: 0;
  font-size: 13px; border-radius: 4px; border: 1px solid rgba(0,0,0,.45);
  cursor: pointer; opacity: .45;
}
.spec:hover .acts button { opacity: .8; }
.spec .acts .ok { background: #2f7d4f; color: #eaffef; }
.spec .acts .no { background: #7d2f2f; color: #ffecec; }

/* status overlay: a mark drawn over the image, under the number + buttons */
.spec::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  display: flex; align-items: flex-end; justify-content: center;
  font: 800 30px/1 system-ui, sans-serif; padding-bottom: 3px;
}

/* --- pending: undecided, stays bright with a plain blue edge --- */
.spec.pending { border-color: #3aa0ff; }

/* --- approved: green frame + glow + wash + a big tick --- */
.spec.accepted { border-color: #37e08a; box-shadow: 0 0 11px -2px #37e08acc; }
.spec.accepted::after {
  content: "\2713";
  color: #baffdc; text-shadow: 0 0 5px #000, 0 1px 2px #000;
  background: linear-gradient(0deg, #37e08a55, transparent 60%);
}
.spec.accepted .n { color: #d7ffe9; }
.spec.accepted .acts .ok {
  opacity: 1; background: #37e08a; color: #05240f;
  box-shadow: 0 0 0 2px #fff, 0 1px 4px #000;
}
.spec.accepted .acts .no { opacity: .18; }

/* --- denied: desaturated, dimmed, red X struck across it --- */
.spec.rejected { border-color: #ff5b5b; }
.spec.rejected img { filter: grayscale(1) brightness(.5) contrast(.9); }
.spec.rejected::after {
  background:
    linear-gradient(to top left,  transparent calc(50% - 2.5px), #ff5b5b calc(50% - 2.5px),
                    #ff5b5b calc(50% + 2.5px), transparent calc(50% + 2.5px)),
    linear-gradient(to top right, transparent calc(50% - 2.5px), #ff5b5b calc(50% - 2.5px),
                    #ff5b5b calc(50% + 2.5px), transparent calc(50% + 2.5px)),
    #ff5b5b22;
}
.spec.rejected .n { text-decoration: line-through; color: #ffd9d9; }
.spec.rejected .acts .no {
  opacity: 1; background: #ff5b5b; color: #2b0000;
  box-shadow: 0 0 0 2px #fff, 0 1px 4px #000;
}
.spec.rejected .acts .ok { opacity: .18; }

/* the specimen under review right now: lifted out of the grid with a bright
   ring + glow so it's obvious which crop the slide view is centred on. The ring
   is an outline so it never fights the status border colour. */
.spec.selected {
  outline: 3px solid #57a8ff; outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(87, 168, 255, .22), 0 10px 26px -6px #000c;
  transform: scale(1.05); z-index: 5;
}
.spec.selected:hover { transform: scale(1.05); }
@media (prefers-reduced-motion: no-preference) {
  .spec.selected { animation: spec-focus .3s ease-out; }
  @keyframes spec-focus {
    from { box-shadow: 0 0 0 15px rgba(87, 168, 255, .38), 0 10px 26px -6px #000c; }
  }
}

#tool-add-specimen.active { background: #8a5cd8; border-color: #8a5cd8; }

/* --- export dialog ---------------------------------------------------- */
dialog#export-dialog {
  background: #26292e; color: #e8e8e8; border: 1px solid #555;
  border-radius: 8px; padding: 16px 18px; min-width: 320px;
}
dialog#export-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
#export-dialog h3 { margin: 0 0 10px; font-size: 15px; }
#export-dialog label { display: block; margin: 8px 0; font-size: 13px; }
#export-dialog input[type="number"] { width: 90px; }
#export-dialog menu { display: flex; gap: 8px; justify-content: flex-end; margin: 14px 0 0; padding: 0; }
#export-dialog menu button {
  padding: 6px 12px; border: 1px solid #555; border-radius: 6px;
  background: #33373d; color: #e8e8e8; cursor: pointer;
}
#export-dialog menu button.primary { background: #2f6fd8; border-color: #2f6fd8; }
#export-error { color: #ff8a8a; font-size: 12px; margin: 6px 0 0; }
#export-error[hidden] { display: none; }
/* <canvas> is a replaced element, so `inset: 0` will NOT stretch it -- it needs
   an explicit width/height to fill the viewer. */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}
#overlay.painting { pointer-events: auto; cursor: crosshair; }

/* Ring that previews the brush footprint while a paint tool is active.
   White ring with a dark halo on both edges so it reads on any background. */
#brush-cursor {
  position: absolute; z-index: 1000; pointer-events: none;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.75);
}
#brush-cursor[hidden] { display: none; }
#brush-cursor.positive { border-color: #46e08c; }
#brush-cursor.negative { border-color: #ff6e6e; }
