.bbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(129, 129, 129, 0.65);
  backdrop-filter: saturate(120%) blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 9998;
}
.bbox-backdrop.is-visible {
  opacity: 0.45;
  visibility: visible;
}
.bbox-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 9999;
}
.bbox-modal.is-visible { opacity: 1; visibility: visible; }

.bbox-modal__panel {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08), 0 24px 64px rgba(0,0,0,0.55);
  width: 80vw;
  max-width: 80vw;
  height: 80vh;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #21262b;
}

.bbox-modal__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1f2a33;
  background-color: #21262b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.bbox-modal__title { font-size: 14px; font-weight: 600; }
.bbox-modal__close { appearance: none; border: 0; background: transparent; cursor: pointer; padding: 4px 8px; font-size: 20px; line-height: 1; color: #fff; opacity: 0.75; transition: opacity .15s ease; }
.bbox-modal__close:hover { opacity: 1; }

/* Button group container */
.bbox-modal__button-group {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Make clear button same size as select button */
.bbox-modal__btn--clear {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border: none;
  background: transparent;
}

/* Clear icon styles */
.clear-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-block;
}

.clear-square {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background-color: #ef4444;
  border-radius: 2px;
}

.clear-x {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
}

.clear-x::before,
.clear-x::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  background-color: white;
  border-radius: 1px;
}

.clear-x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.clear-x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Remove individual button positioning */
.bbox-modal__header .bbox-modal__btn.bbox-modal__select { 
  position: static; 
  transform: none; 
}

/* Right group (search + close) */
.bbox-modal__header-right { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; position: relative; }

/* Search results panel */
.bbox-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #2a3137;
  border: 1px solid #2f363c;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  overflow: hidden;
  animation: resultsSlideIn 0.2s ease-out;
}

.bbox-search-results__item {
  padding: 12px 16px;
  color: #9aa4ae;
  font-size: 13px;
  text-align: left;
  border-bottom: 1px solid #2f363c;
}

.bbox-search-results__item:last-child {
  border-bottom: none;
}

@keyframes resultsSlideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Selection icon styles */
.selection-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-block;
}

.selection-icon .corner {
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  position: absolute;
}

.selection-icon .top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.selection-icon .top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
}

.selection-icon .bottom-left {
  bottom: 0;
  left: 0;
  border-top: none;
  border-right: none;
}

.selection-icon .bottom-right {
  bottom: 0;
  right: 0;
  border-top: none;
  border-left: none;
}

.selection-icon .center-box {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background-color: transparent !important;
  border: 2px solid currentColor;
  transform: translate(-50%, -50%);
}

/* Search input style */
.bbox-modal__search { width: 320px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid #2f363c; background: #2a3137; color: #e6edf3; outline: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.bbox-modal__search::placeholder { color: #9aa4ae; opacity: .9; }
.bbox-modal__search:hover { border-color: #3a4148; }
.bbox-modal__search:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.25), inset 0 1px 0 rgba(255,255,255,0.06); background: #263038; }
.bbox-modal__search.is-error { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25), inset 0 1px 0 rgba(255,255,255,0.04); background: #262226; }

.bbox-modal__body { padding: 12px 16px; flex: 1; display: flex; overflow: hidden; }

.bbox-modal__footer {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 14px 16px;
  border-top: 1px solid #1f2a33;
  background-color: #21262b;
  color: #fff;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.35);
}

.bbox-modal__btn {
  appearance: none;
  border-radius: 10px;
  padding: 0 18px;
  height: 42px;
  min-width: 140px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow .15s ease, background-color .15s ease, border-color .15s ease, transform .05s ease, opacity .15s ease;
  opacity: 0.95;
}
.bbox-modal__btn--icon { padding: 0; width: 34px; min-width: 34px; height: 34px; }
.bbox-modal__btn svg { pointer-events: none; }
.bbox-modal__btn:hover { border-color: rgba(255,255,255,0.4); opacity: 1; }
.bbox-modal__btn:active { transform: translateY(1px); }
.bbox-modal__btn.is-active,
.bbox-modal__btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35), 0 0 0 1px #2563eb inset; }

/* Footer variants */
.bbox-modal__btn--ghost { background: #3b444c; border-color: #3b444c; color: #e6edf3; }
.bbox-modal__btn--ghost:hover { background: #485159; border-color: #485159; }
.bbox-modal__btn--primary { background: #2563eb; border-color: #2563eb; color: #fff;}
.bbox-modal__btn--primary:hover { background: #1f56d6; border-color: #1f56d6; }

/* Transparent button variant */
.bbox-modal__btn--transparent { 
  background: transparent; 
  border: none; 
  color: #fff;
  box-shadow: none;
}
.bbox-modal__btn--transparent:hover { 
  background: transparent; 
  border: none; 
  box-shadow: none;
}
.bbox-modal__btn--transparent.is-active { 
  background: transparent; 
  border: none; 
  box-shadow: none;
}

.bbox-modal__btn--transparent.is-active .selection-icon {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6), 0 0 40px rgba(255, 255, 255, 0.3);
}

.bbox-modal__btn--transparent.is-active svg {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6), 0 0 40px rgba(255, 255, 255, 0.3);
}

.bbox-modal__btn--transparent.is-active .clear-icon {
  box-shadow: none; /* turn off glow for clear button */
}

/* Disabled buttons */
.bbox-modal__btn[disabled] { opacity: 0.55; cursor: not-allowed; box-shadow: none !important; filter: saturate(70%); }
.bbox-modal__btn[disabled]:hover { opacity: 0.55; border-color: inherit; }
.bbox-modal__btn--primary[disabled] { background: #1f4ed8; border-color: #1f4ed8; color: rgba(255,255,255,0.85); }

/* Disabled clear button */
.bbox-modal__btn--clear.bbox-modal__btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Active clear button */
.bbox-modal__btn--clear.is-active {
  cursor: pointer;
  pointer-events: auto;
}

.bbox-modal__btn--clear.bbox-modal__btn--disabled .clear-square {
  background-color: #6b7280;
}

.bbox-modal__btn--clear.bbox-modal__btn--disabled .clear-x::before,
.bbox-modal__btn--clear.bbox-modal__btn--disabled .clear-x::after {
  background-color: #9ca3af;
}

.bbox-modal__content { flex: 1; min-height: 0; }
#bbox-map { width: 100%; height: 100%; }
#bbox-map.is-selecting { cursor: crosshair; }

.tile-map-polygon-label-base { color: #3470FC; width: max-content; display: flex !important; justify-content: center; font-weight: bold; font-size: 14px; line-height: 0.9em; opacity: 0.8; }
.tile-map-polygon-label-base > div > span { color: #A7B8C4; }