:root {
  --microscope-brass: #d39a3b;
  --microscope-metal: #536a61;
  --microscope-glass: #8cc9c1;
}

.microscope-layout {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 22vw, 310px);
  grid-template-rows: 38px minmax(0, 1fr);
  background:
    radial-gradient(circle at 45% 35%, rgba(255, 255, 255, 0.96), rgba(234, 246, 242, 0.74) 52%, rgba(230, 238, 230, 0.88)),
    linear-gradient(180deg, #f7fbf8, #eef5ef);
}

.microscope-viewport {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.microscope-viewport:active { cursor: grabbing; }
.microscope-host,
.microscope-labels { position: absolute; inset: 0; }
.microscope-host canvas { display: block; width: 100%; height: 100%; }
.microscope-labels { z-index: 3; pointer-events: none; }
.microscope-label-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.microscope-label-leaders line { stroke: #94b2a5; stroke-width: 1; opacity: 0.75; }
.microscope-labels.is-compact-labels .microscope-label { font-size: 9px; padding: 2px 5px; box-shadow: none; }

.microscope-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate3d(0, 0, 0) translate(-50%, -50%);
  transform-origin: center;
  will-change: transform, opacity;
  backface-visibility: hidden;
  contain: layout style paint;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--label-color) 28%, #d7e4df);
  border-radius: 10px;
  color: var(--label-color, #245f52);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 7px 18px rgba(39, 70, 63, 0.11);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.15;
  white-space: nowrap;
  transition: opacity 160ms ease;
}

.microscope-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  color: #3e7668;
  background: rgba(247, 251, 249, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.microscope-loading[hidden] { display: none; }

.microscope-sidepanel {
  grid-column: 2;
  grid-row: 1 / -1;
  min-width: 0;
  overflow: auto;
  padding: 14px;
  border-left: 1px solid rgba(188, 210, 204, 0.86);
  background: rgba(252, 254, 252, 0.9);
}

.microscope-sidepanel h2 {
  margin: 0;
  color: #245f52;
  font-size: 17px;
}

.microscope-sidepanel h2 small {
  display: block;
  margin-top: 3px;
  color: #7b918a;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.microscope-panel-note {
  margin: 9px 0 12px;
  color: #6b817a;
  font-size: 11px;
  line-height: 1.55;
}

.microscope-part-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.microscope-part-button,
.microscope-objective-button {
  min-width: 0;
  padding: 8px;
  border: 1px solid #d5e4df;
  border-radius: 12px;
  color: #365f54;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.microscope-part-button:hover,
.microscope-part-button:focus-visible,
.microscope-objective-button:hover,
.microscope-objective-button:focus-visible {
  border-color: #5a9b89;
  outline: none;
  transform: translateY(-1px);
}

.microscope-part-button strong,
.microscope-part-button span { display: block; overflow-wrap: anywhere; }
.microscope-part-button strong { font-size: 11px; }
.microscope-part-button span { margin-top: 2px; color: #86968f; font-size: 8px; }
.microscope-part-button.is-active,
.microscope-objective-button.is-active {
  border-color: #31816e;
  color: #fff;
  background: linear-gradient(145deg, #56ad94, #287a66);
  box-shadow: 0 7px 17px rgba(40, 122, 102, 0.18);
}
.microscope-part-button.is-active span { color: rgba(255, 255, 255, 0.72); }

.microscope-control-block {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid #e0ebe7;
}

.microscope-control-block h3 {
  margin: 0 0 8px;
  color: #58736b;
  font-size: 11px;
}

.microscope-objectives { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.microscope-objective-button { text-align: center; font-size: 11px; font-weight: 850; }
.microscope-mirror-control { margin-top: 12px; }
.microscope-mirror-control h3 { margin-bottom: 7px; }
.microscope-mirror-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }

.microscope-range {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: #58736b;
  font-size: 10px;
  font-weight: 750;
}
.microscope-range span { display: flex; justify-content: space-between; gap: 10px; }
.microscope-range output { color: #31816e; }
.microscope-range input { width: 100%; accent-color: #31816e; }
.microscope-range.is-locked {
  color: #8a9a95;
}
.microscope-range.is-locked input {
  cursor: not-allowed;
  opacity: 0.42;
}
.microscope-range.is-locked output {
  color: #b36f32;
}

.microscope-field-card {
  margin-top: 13px;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dce8e4;
  border-radius: 15px;
  background: #fff;
}

.microscope-field-view {
  --cell-scale: 0.78;
  position: relative;
  width: 70px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 5px solid #294940;
  border-radius: 50%;
  background: radial-gradient(circle, #fffde8, #e4ddb5 72%, #9d9879);
  box-shadow: inset 0 0 13px rgba(41, 50, 42, 0.26);
  transition: filter 180ms ease;
}

.microscope-field-cell {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 25px;
  border: 1.5px solid rgba(79, 125, 79, 0.8);
  border-radius: 42% 58% 46% 54%;
  background: rgba(109, 165, 91, 0.24);
  transform: translate(-50%, -50%) scale(var(--cell-scale));
  transform-origin: center;
  transition: transform 320ms ease;
}
.microscope-field-cell::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: rgba(92, 64, 131, 0.72);
  transform: translate(-50%, -50%);
}

.microscope-field-copy strong,
.microscope-field-copy span { display: block; }
.microscope-field-copy strong { color: #294f45; font-size: 12px; }
.microscope-field-copy span { margin-top: 4px; color: #7a8e87; font-size: 9px; line-height: 1.45; }

.microscope-status {
  position: static;
  margin: 10px 0;
  padding: 9px 12px;
  border: 1px solid rgba(188, 210, 204, 0.82);
  border-radius: 13px;
  color: #4f6b63;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(31, 66, 57, 0.09);
  font-size: 10px;
  line-height: 1.55;
}
.microscope-status strong { color: #245f52; }
.microscope-status[hidden] { display: none; }

