.lead-lab {
  --lab-navy: #102a43;
  --lab-blue: #0878d1;
  --lab-blue-soft: #eaf5ff;
  --lab-green: #158765;
  --lab-amber: #b96500;
  --lab-red: #c43d4b;
  padding: clamp(1rem, 2.5vw, 2rem);
  background: linear-gradient(145deg, #f8fbff 0%, #eef6ff 100%);
}

.quick-check-button {
  border-color: #0878d1;
  background: #0878d1;
  color: #fff;
}

.quick-check-button:hover { background: #0065b3; }

/* Every mode includes measurement before placement; assessment hides the worked answers. */
.lead-lab-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.lead-lab-header h2 {
  margin: 0.2rem 0 0.55rem;
  color: var(--lab-navy);
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  letter-spacing: -0.03em;
}

.lead-lab-header p {
  max-width: 760px;
  margin: 0;
  color: #526579;
  line-height: 1.65;
}

.eyebrow,
.step-kicker {
  color: var(--lab-blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.lab-mode-switcher {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 0.3rem;
  border: 1px solid #c9d9e8;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(16, 42, 67, 0.08);
}

.lab-mode {
  min-height: 40px;
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #526579;
  font-weight: 700;
  cursor: pointer;
}

.lab-mode.active {
  background: var(--lab-navy);
  color: #fff;
}

.lab-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  padding: 0;
  margin: 0 0 1.25rem;
  list-style: none;
}

.lab-step {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem;
  border: 1px solid #d5e1ec;
  border-radius: 12px;
  background: rgba(255,255,255,0.75);
  color: #526579;
  font-weight: 750;
  cursor: pointer;
}

.lab-step span {
  width: 27px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #dce8f2;
  color: var(--lab-navy);
  font-size: 0.8rem;
}

.lab-step.active,
.lab-step.completed {
  border-color: #7ebbea;
  background: #fff;
  color: var(--lab-blue);
}

.lab-step.active span,
.lab-step.completed span {
  background: var(--lab-blue);
  color: #fff;
}

.lead-lab-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.85fr) minmax(430px, 1.4fr);
  gap: 1.25rem;
  align-items: stretch;
}

.lab-instruction-card,
.lab-workspace {
  border: 1px solid #d7e3ee;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(16, 42, 67, 0.08);
}

.lab-instruction-card {
  min-height: 590px;
  padding: clamp(1rem, 2.4vw, 1.6rem);
  display: flex;
  flex-direction: column;
}

.lab-step-panel { display: none; }
.lab-step-panel.active { display: block; }

.lab-step-panel h3 {
  margin: 0.45rem 0 1rem;
  color: var(--lab-navy);
  font-size: 1.25rem;
}

.landmark-list {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.landmark-list div {
  padding: 0.75rem 0.85rem;
  border-left: 3px solid #73b8ed;
  border-radius: 0 10px 10px 0;
  background: #f5faff;
}

.landmark-list dt { color: var(--lab-navy); font-weight: 800; }
.landmark-list dd { margin: 0.2rem 0 0; color: #53687b; line-height: 1.45; }

.lab-note {
  margin-top: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: #fff8e8;
  color: #674914;
  font-size: 0.9rem;
  line-height: 1.5;
}

.measurement-fields {
  display: grid;
  gap: 0.7rem;
}

.measurement-fields label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #314b61;
  font-weight: 650;
}

.measurement-fields input {
  width: 76px;
  min-height: 42px;
  padding: 0.4rem 0.55rem;
  border: 1px solid #afc4d7;
  border-radius: 8px;
  font: inherit;
}

.measurement-output {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}

.measurement-result {
  padding: 0.7rem;
  border: 1px solid #cfe0ee;
  border-radius: 10px;
  background: var(--lab-blue-soft);
}

.measurement-result strong,
.measurement-result span { display: block; }
.measurement-result strong { color: var(--lab-navy); font-size: 1.05rem; }
.measurement-result span { color: #607487; font-size: 0.78rem; }

.electrode-progress {
  display: grid;
  gap: 0.35rem;
  margin: 0.8rem 0;
  color: #526579;
  font-size: 0.86rem;
}

.electrode-progress progress { width: 100%; accent-color: var(--lab-blue); }

.electrode-palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 0.45rem;
  max-height: 245px;
  overflow: auto;
  padding: 0.15rem;
}

.electrode-bin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.9rem 0 0.45rem;
  color: var(--lab-navy);
  font-weight: 800;
}

.electrode-bin-header small {
  color: #6a7d8e;
  font-size: 0.75rem;
  font-weight: 650;
}

.electrode-choice {
  min-height: 43px;
  padding: 0.35rem;
  border: 1px solid #b9cbd9;
  border-radius: 9px;
  background: #fff;
  color: var(--lab-navy);
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
}

.electrode-choice:hover,
.electrode-choice:focus-visible,
.electrode-choice.selected {
  border-color: var(--lab-blue);
  background: var(--lab-blue-soft);
  color: #005da8;
}

.electrode-choice.placed { background: #edf9f4; border-color: #7ac5ab; color: #116f54; }
.electrode-choice.dragging { opacity: 0.5; transform: scale(0.96); }

.electrode-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100000;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #0878d1;
  color: #fff;
  box-shadow: 0 12px 32px rgba(16, 42, 67, 0.38);
  font: 800 0.8rem Inter, sans-serif;
  line-height: 1;
  pointer-events: none;
  will-change: transform;
}

body.electrode-is-dragging {
  cursor: grabbing;
  user-select: none;
}

.verification-list {
  display: grid;
  gap: 0.7rem;
  padding: 0;
  list-style: none;
}

.verification-list li {
  position: relative;
  padding: 0.65rem 0.7rem 0.65rem 2.35rem;
  border-radius: 9px;
  background: #f4f7fa;
  color: #526579;
}

.verification-list li::before {
  content: "○";
  position: absolute;
  left: 0.8rem;
  color: #8395a5;
  font-weight: 900;
}

.verification-list li.passed { background: #eaf8f2; color: #116b50; }
.verification-list li.passed::before { content: "✓"; color: var(--lab-green); }

.lab-results { min-height: 48px; margin-top: 0.75rem; line-height: 1.45; }
.lab-results.success { color: var(--lab-green); }
.lab-results.warning { color: var(--lab-amber); }

.lab-navigation {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1.25rem;
}

.lab-workspace {
  min-width: 0;
  overflow: hidden;
}

.head-toolbar {
  min-height: 72px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #dce6ef;
}

.head-toolbar > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.head-toolbar strong,
.head-toolbar span { display: block; }
.head-toolbar strong { color: var(--lab-navy); }
.head-toolbar span {
  margin-top: 0.15rem;
  color: #63788a;
  font-size: 0.8rem;
  line-height: 1.35;
  /* Reserve space for mode banners so the head diagram does not jump. */
  min-height: 72px;
}

.head-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 0 auto;
  align-self: flex-start;
}

.icon-button {
  min-height: 40px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #c9d8e4;
  border-radius: 9px;
  background: #fff;
  color: #365167;
  font-weight: 700;
  cursor: pointer;
}

.icon-button:disabled { opacity: 0.45; cursor: not-allowed; }

.head-stage {
  min-height: 510px;
  display: grid;
  place-items: center;
  padding: 0.5rem;
  background: radial-gradient(circle at center, #ffffff 0%, #f2f7fb 75%);
}

.head-stage.drag-over {
  background: radial-gradient(circle at center, #fff 0%, #e0f3ff 78%);
  box-shadow: inset 0 0 0 4px rgba(8, 120, 209, 0.3);
}

#lead-lab-svg {
  display: block;
  width: min(100%, 424px);
  height: auto;
  aspect-ratio: 400 / 500;
  touch-action: none;
  cursor: crosshair;
}

.scalp-shape { fill: #e6e6e6; stroke: #17364d; stroke-width: 3; }
.nose-shape,
.ear-shape { fill: #d4d4d4; stroke: #17364d; stroke-width: 3; }

.measurement-guides path,
.measurement-guides ellipse {
  fill: none;
  stroke: #8fb7d5;
  stroke-width: 1.5;
  stroke-dasharray: 7 6;
}

.landmark-markers circle { fill: #e56b6f; stroke: #fff; stroke-width: 2; }
.landmark-markers text { fill: #8d3541; font-size: 12px; font-weight: 800; text-anchor: middle; }

.target-site circle {
  fill: rgba(8,120,209,0.08);
  stroke: rgba(8,120,209,0.45);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.target-site text { fill: #4a6b84; font-size: 11px; font-weight: 750; text-anchor: middle; }
.target-site.hint circle { fill: rgba(241,155,44,0.3); stroke: #d87900; stroke-width: 3; }
.lead-lab[data-mode="practice"] .target-site text { display: none; }
.lead-lab[data-mode="assessment"] .target-layer,
.lead-lab[data-mode="assessment"] .measurement-guides { opacity: 0; }

.placed-site { cursor: grab; }
.placed-site.dragging { cursor: grabbing; }
.placed-site circle { fill: var(--lab-blue); stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 3px 4px rgba(16,42,67,0.25)); }
.placed-site text { fill: #fff; font-size: 10px; font-weight: 850; text-anchor: middle; pointer-events: none; }
.placed-site.selected circle { fill: #f19b2c; }
.placed-site.correct circle { fill: var(--lab-green); }
.placed-site.incorrect circle { fill: var(--lab-red); }

.head-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem 1.75rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #dce6ef;
  color: #63788a;
  font-size: 0.78rem;
  line-height: 1.2;
}

.head-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.head-legend-mark {
  display: block;
  flex: none;
  width: 12px;
  height: 12px;
  overflow: visible;
}

.lab-mode:focus-visible,
.lab-step:focus-visible,
.icon-button:focus-visible,
.electrode-choice:focus-visible,
#lead-lab-svg:focus-visible {
  outline: 3px solid rgba(8,120,209,0.35);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .lead-lab-header { flex-direction: column; gap: 1rem; }
  .lead-lab-grid { grid-template-columns: 1fr; }
  .lab-instruction-card { min-height: auto; }
  .head-stage { min-height: 450px; }
}

@media (max-width: 620px) {
  .lead-lab { padding: 0.75rem; }
  .lab-mode-switcher { width: 100%; }
  .lab-mode { flex: 1; }
  .lab-steps { grid-template-columns: repeat(2, 1fr); }
  .lab-step { justify-content: flex-start; min-height: 48px; }
  .measurement-output { grid-template-columns: 1fr; }
  .electrode-palette { grid-template-columns: repeat(4, 1fr); max-height: none; }
  .head-toolbar { align-items: flex-start; flex-direction: column; }
  .head-toolbar-actions { width: 100%; }
  .icon-button { flex: 1; }
  .head-stage { min-height: 390px; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .lead-lab *, .lead-lab *::before, .lead-lab *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/*-----------------------------------------------
  DARK MODE: 10-20 PLACEMENT LAB
  Same problem as eeg-lead-simulator.css: every surface here is
  hardcoded light. The head diagram itself deliberately stays light;
  a schematic scalp reads better as a light form on a dark stage.
-----------------------------------------------*/
body.dark .lead-lab {
  background: linear-gradient(145deg, #232326 0%, #1c1c1f 100%);
  border-color: var(--border-color);
}

body.dark .lab-mode-switcher,
body.dark .lab-workspace,
body.dark .icon-button,
body.dark .electrode-choice,
body.dark .lab-step.completed {
  background: #3a3a3c;
  border-color: var(--border-color);
  color: var(--text-color);
}

body.dark .lab-instruction-card,
body.dark .landmark-list div,
body.dark .verification-list li,
body.dark .measurement-result {
  background: #2f2f31;
  border-color: var(--border-color);
  color: var(--text-color);
}

body.dark .lab-instruction-card h3,
body.dark .lab-instruction-card dt,
body.dark .measurement-fields label,
body.dark .electrode-progress,
body.dark .electrode-bin-header,
body.dark .head-toolbar,
body.dark .head-legend,
body.dark .lead-lab h2,
body.dark .lead-lab p {
  color: var(--text-color);
}

body.dark .lab-instruction-card dd,
body.dark .step-kicker,
body.dark .head-toolbar span,
body.dark .electrode-bin-header small {
  color: var(--text-secondary);
}

body.dark .lab-note {
  background: rgba(255, 193, 7, 0.12);
  border-color: rgba(255, 193, 7, 0.3);
  color: var(--text-color);
}

body.dark .verification-list li.passed {
  background: rgba(76, 175, 80, 0.18);
  color: #a5e8a8;
}

body.dark .electrode-choice.placed {
  background: rgba(76, 175, 80, 0.2);
  border-color: #4caf50;
  color: #a5e8a8;
}

body.dark .measurement-fields input {
  background: #3a3a3c;
  color: var(--text-color);
  border-color: var(--border-color);
}

/* Keep the head schematic light-on-dark for legibility */
body.dark .head-stage {
  background: radial-gradient(circle at center, #e8eef4 0%, #cdd9e4 78%);
  border-color: var(--border-color);
}

body.dark .lab-results.success {
  background: rgba(76, 175, 80, 0.18);
  color: #a5e8a8;
}

body.dark .lab-results.warning {
  background: rgba(255, 193, 7, 0.18);
  color: #ffd98a;
}

/* Assessment mode blanks the target layer with opacity:0, which also blanked
   the Hint highlight, the one mode where a hint is needed. Let a hinted
   target surface through on its own. */
.lead-lab[data-mode="assessment"] .target-site.hint {
  opacity: 1;
}
.lead-lab[data-mode="assessment"] .target-site.hint text {
  display: none;
}
.target-site.hint circle {
  animation: lab-hint-pulse 0.9s ease-in-out 3;
}
@keyframes lab-hint-pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .target-site.hint circle { animation: none; }
}

body.dark .head-toolbar strong,
body.dark .head-toolbar div,
body.dark #lab-selection-status { color: var(--text-color); }
body.dark .lab-mode { color: #c3ccd6; }
body.dark .lab-mode.active { color: #fff; }
