.body-map-body {
  overflow: hidden;
}

.body-map-shell,
.body-map-workspace {
  min-height: 0;
}

.body-map-title {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.body-map-title strong {
  color: var(--ink);
  font-size: 15px;
}

.body-map-title span {
  color: var(--muted);
  font-size: 10px;
}

.body-map-topbar-actions {
  margin-left: auto;
}

.body-map-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 360px;
  overflow: hidden;
  background: #0f1818;
}

.body-map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0f1818;
}

.body-map-controls {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  display: flex;
  max-width: calc(100% - 28px);
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.body-map-controls > * {
  pointer-events: auto;
}

.segmented-control {
  display: inline-grid;
  min-width: 0;
  height: 40px;
  align-items: stretch;
  padding: 3px;
  border: 1px solid rgba(214, 230, 227, 0.26);
  border-radius: 6px;
  background: rgba(20, 38, 39, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(10px);
}

.body-view-control {
  grid-template-columns: repeat(3, minmax(50px, auto));
}

.body-mode-control {
  grid-template-columns: repeat(2, minmax(76px, auto));
}

.segmented-control button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 0;
  border-radius: 4px;
  color: #b9cbca;
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.segmented-control button:hover {
  color: #ffffff;
}

.segmented-control button.active {
  color: #ffffff;
  background: #177f77;
}

.body-map-clear {
  width: 40px;
  height: 40px;
  border-color: rgba(214, 230, 227, 0.28);
  color: #f2f7f6;
  background: rgba(20, 38, 39, 0.9);
  backdrop-filter: blur(10px);
}

.body-map-clear:hover:not(:disabled) {
  border-color: #e37a65;
  color: #ffffff;
  background: #9f493d;
}

.body-map-clear:disabled {
  opacity: 0.42;
}

.body-map-canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#bodyMapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
  touch-action: none;
}

body.body-map-draw #bodyMapCanvas {
  cursor: crosshair;
}

body.body-map-orbiting #bodyMapCanvas {
  cursor: grabbing;
}

.body-map-orientation,
.body-map-hit-label {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 1px solid rgba(214, 230, 227, 0.25);
  border-radius: 4px;
  color: #e8f1ef;
  background: rgba(17, 31, 31, 0.76);
  font-size: 11px;
  font-weight: 750;
  backdrop-filter: blur(8px);
}

.body-map-orientation {
  right: 14px;
  bottom: 14px;
  padding: 7px 9px;
}

.body-map-hit-label {
  left: 50%;
  bottom: 14px;
  max-width: calc(100% - 180px);
  transform: translateX(-50%);
  padding: 7px 10px;
  text-align: center;
}

.body-map-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  color: #d8e5e2;
  background: #0f1818;
  font-size: 13px;
  transition: opacity 180ms ease;
}

.body-map-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.body-map-results {
  position: relative;
  z-index: 6;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  color: var(--ink);
  background: #ffffff;
}

.body-map-results > header {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.body-map-results h1,
.body-map-results h2,
.body-map-results p {
  margin: 0;
}

.body-map-results h1 {
  margin-top: 3px;
  font-size: 19px;
  line-height: 1.2;
}

.body-map-results .eyebrow {
  color: var(--teal);
  font-size: 10px;
  font-weight: 850;
}

.body-map-result-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.body-map-empty {
  display: grid;
  min-height: 200px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 30px;
  color: var(--quiet);
  text-align: center;
}

.body-map-empty .icon {
  width: 30px;
  height: 30px;
  color: #9aaba9;
}

.body-map-empty strong {
  font-size: 13px;
}

.body-map-result-content {
  display: grid;
}

.body-map-result-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.body-map-result-section h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.body-map-zone-list,
.body-map-nerve-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.body-map-zone,
.body-map-nerve {
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.body-map-zone {
  color: #345653;
  background: #e6f2ef;
}

.body-map-nerve {
  color: #6a4b12;
  background: #fff2c7;
}

.body-map-candidate-list {
  display: grid;
}

.body-map-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid #edf0ef;
}

.body-map-candidate:last-child {
  border-bottom: 0;
}

.body-map-candidate strong,
.body-map-candidate small {
  display: block;
}

.body-map-candidate strong {
  font-size: 12px;
  line-height: 1.35;
}

.body-map-candidate small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.body-map-candidate a {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #b7d5d0;
  border-radius: 5px;
  color: var(--teal);
  background: #f5fbf9;
  text-decoration: none;
}

.body-map-candidate a:hover {
  color: #ffffff;
  background: var(--teal);
}

.body-map-candidate a .icon {
  width: 16px;
  height: 16px;
}

.body-map-checks {
  background: #fffaf5;
}

.body-map-checks ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.body-map-checks li {
  position: relative;
  padding-left: 13px;
  color: #655b50;
  font-size: 10px;
  line-height: 1.55;
}

.body-map-checks li::before {
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #dc6f55;
  content: "";
}

.body-map-boundary {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  padding: 14px 18px;
  color: #6b5a2f;
  background: #fff5d8;
}

.body-map-boundary .icon {
  width: 17px;
  height: 17px;
  color: #a77812;
}

.body-map-boundary p {
  font-size: 10px;
  line-height: 1.5;
}

.body-map-sources {
  display: grid;
  gap: 6px;
  padding: 14px 18px 24px;
}

.body-map-sources a {
  color: var(--teal);
  font-size: 9px;
  line-height: 1.45;
  text-decoration: none;
}

.body-map-sources a:hover {
  text-decoration: underline;
}

@media (max-width: 1120px) {
  .body-map-main {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .body-map-controls {
    flex-wrap: wrap;
  }
}

@media (max-width: 820px) {
  .body-map-body {
    overflow: auto;
  }

  .body-map-workspace {
    min-height: 100vh;
    grid-template-rows: 60px minmax(0, 1fr);
  }

  .body-map-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(520px, 70vh) auto;
    overflow: visible;
  }

  .body-map-results {
    min-height: 360px;
    overflow: visible;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .body-map-results > header {
    position: static;
  }

  .body-map-topbar {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .body-map-topbar-actions .icon-button:nth-child(1) {
    display: none;
  }

  .body-map-controls {
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    gap: 6px;
  }

  .segmented-control {
    height: 38px;
  }

  .segmented-control button {
    padding: 0 8px;
    font-size: 11px;
  }

  .body-view-control {
    grid-template-columns: repeat(3, minmax(43px, auto));
  }

  .body-mode-control {
    grid-template-columns: repeat(2, minmax(66px, auto));
  }

  .body-map-clear {
    width: 38px;
    height: 38px;
  }

  .body-map-orientation {
    right: 10px;
    bottom: 10px;
  }

  .body-map-hit-label {
    bottom: 10px;
    max-width: calc(100% - 100px);
  }
}

@media (max-width: 430px) {
  .body-map-title span {
    display: none;
  }

  .body-map-topbar-actions .icon-button:nth-child(2) {
    display: none;
  }

  .body-map-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .body-view-control {
    grid-column: 1 / -1;
  }

  .body-mode-control {
    width: 100%;
  }

  .body-map-main {
    grid-template-rows: minmax(510px, 68vh) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .body-map-loading {
    transition: none;
  }
}
