.boundary-editor {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #17352a;
  color: #fff;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
  font-family: inherit;
}
.boundary-editor[open] {
  display: grid;
}
.boundary-editor::backdrop {
  background: #102b20;
}
.be-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}
.be-head > div {
  text-align: center;
  min-width: 0;
}
.be-name {
  display: block;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.be-area {
  display: block;
  font-weight: 750;
  font-size: 23px;
}
.be-perimeter {
  display: block;
  color: #cfdfd4;
  font-size: 12px;
}
.boundary-editor button {
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
}
.be-head button,
.be-tools button {
  background: #fff;
  color: #17352a;
  border: 0;
  padding: 8px 12px;
}
.boundary-editor button.primary {
  background: #e1f7a5;
  color: #183b2a;
  font-weight: 700;
}
.boundary-editor button:disabled {
  opacity: 0.45;
  cursor: default;
}
.be-map {
  position: relative;
  min-height: 0;
  width: 100%;
  background: #c2cec3;
  isolation: isolate;
}
.be-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 650;
  overflow: hidden;
}
.boundary-editor .be-point,
.boundary-editor .be-mid {
  position: absolute;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  display: grid;
  place-items: center;
}
.be-point span {
  width: 15px;
  height: 15px;
  background: #fff;
  border: 3px solid #264634;
  border-radius: 50%;
  box-shadow: 0 1px 5px #0009;
}
.be-point.selected {
  z-index: 4;
}
.be-point.selected span {
  width: 19px;
  height: 19px;
  background: #e5fa7f;
  border-color: #17352a;
  box-shadow:
    0 0 0 6px #ffffff99,
    0 1px 6px #000;
}
.boundary-editor .be-mid {
  color: #17352a;
  font-weight: bold;
  font-size: 20px;
  background: radial-gradient(circle, #ffffffb8 0 10px, transparent 11px);
}
.be-length {
  position: absolute;
  left: 0;
  top: 0;
  background: #fffef2ee;
  color: #1d3226;
  padding: 3px 8px;
  border-radius: 6px;
  font: 600 13px/18px system-ui;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px #0005;
}
.boundary-editor [hidden] {
  display: none !important;
}
.be-foot {
  padding: 6px 10px calc(10px + env(safe-area-inset-bottom));
  background: #17352a;
}
.be-hint {
  margin: 0 0 7px;
  font-size: 12px;
  color: #e1ebdf;
  text-align: center;
}
.be-tools {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.be-tools button {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
}
.be-error,
.be-save-error {
  color: #ffd2be;
  font-size: 13px;
  margin: 5px 0 0;
}
.be-error:empty,
.be-save-error:empty {
  display: none;
}
.be-confirm {
  position: absolute;
  z-index: 1000;
  inset: auto 0 0;
  background: #17352a;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 80px #0008;
}
.be-confirm button {
  padding: 10px 15px;
  margin: 4px 4px 0 0;
}
.be-confirm-metrics {
  line-height: 1.8;
}
.be-confirm h2 {
  margin-top: 0;
}
.boundary-editor .leaflet-control-zoom a {
  width: 44px;
  height: 44px;
  line-height: 44px;
}
.boundary-preview-tools {
  margin: 12px 0;
}
.field-editor .map-tools[hidden] {
  display: none !important;
}
@media (min-width: 900px) {
  .be-head,
  .be-foot {
    padding-left: max(16px, calc((100vw - 850px) / 2));
    padding-right: max(16px, calc((100vw - 850px) / 2));
  }
  .be-confirm {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
}
.boundary-editor * {
  box-sizing: border-box;
}
.boundary-editor .be-point,
.boundary-editor .be-mid {
  margin: 0;
}
.be-length {
  height: 24px;
}
.boundary-editor {
  border-radius: 0;
}
.be-hint {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.be-confirm[hidden] {
  pointer-events: none;
}
.be-head {
  min-height: calc(86px + env(safe-area-inset-top));
}
.be-area {
  font-size: clamp(18px, 5.6vw, 23px);
  white-space: nowrap;
}
.be-head button {
  flex: none;
  font-size: 14px;
}
.be-head > div {
  flex: 1;
}
.be-map {
  touch-action: none;
}
.be-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 48px;
  gap: 6px;
}
.be-tools button {
  margin: 0;
  min-width: 0;
  padding: 8px 4px;
  font-size: 12px;
}
.be-tools [data-be-action='undo'] {
  grid-area: 1/1;
}
.be-tools [data-be-action='redo'] {
  grid-area: 1/2;
}
.be-tools [data-be-action='delete'],
.be-tools [data-be-action='close'] {
  grid-area: 1/3;
}
.be-foot {
  position: relative;
}
.be-error:not(:empty) {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #17352af2;
  z-index: 700;
}
.be-confirm {
  max-height: 85%;
  overflow: auto;
  overscroll-behavior: contain;
}
.be-name-label,
.be-save-choice-label {
  display: grid;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.be-name-input,
.be-save-choice {
  display: block;
  width: 100%;
  min-height: 48px;
  font: inherit;
  font-size: 16px;
  border: 1px solid #b3c3ad;
  border-radius: 10px;
  background: #fff;
  color: #17352a;
  padding: 12px;
}
.be-confirm-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.be-confirm-actions button {
  margin: 0;
  width: 100%;
  font-size: 15px;
}
.be-confirm-actions [data-be-action='save'] {
  grid-row: 1;
}
.be-confirm-metrics {
  font-size: 14px;
}
.be-confirm > p:not(.be-save-error) {
  font-size: 13px;
}
.be-point.selected {
  will-change: transform;
}
.boundary-editor button:focus-visible,
.be-name-input:focus-visible {
  outline: 3px solid #82d7ff;
  outline-offset: 2px;
}

.be-save-choice-label {
  margin-top: 14px;
}
.be-save-choice {
  font-size: 14px;
}

.be-help {
  margin: 0 0 6px;
  color: #e1ebdf;
  font-size: 13px;
}
.be-help summary {
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: underline;
}
.be-help-content {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  max-height: 65dvh;
  overflow: auto;
  overscroll-behavior: contain;
  z-index: 900;
  background: #fff;
  color: #17352a;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 -8px 30px #0005;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
}
.be-help-content img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 420px;
  margin: auto;
}
.be-help-content ol {
  padding-left: 22px;
}
.be-help-content li {
  margin: 8px 0;
}
.be-help-content p {
  font-size: 12px;
}
.boundary-editor .be-help-close {
  width: 100%;
  background: #17352a;
  color: white;
  border: 0;
}
@media (min-width: 700px) {
  .be-help-content {
    max-width: 520px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 32px);
  }
}
