#editToolbox {
  display: none !important;
}

#editToolHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 700;
  color: #c9d7ea;
}

#editToolButtons {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

#editToolButtons button {
  appearance: none;
  border: 1px solid var(--vm-color-legacy-border-soft);
  background: var(--vm-color-legacy-dark-surface);
  color: var(--vm-color-legacy-text-on-dark);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-weight: 700;
}

#editToolButtons button.active {
  border-color: var(--vm-color-accent-primary);
  background: var(--vm-color-accent-primary-soft);
  color: #eef7ff;
}

#editToolButtons button.delete.active {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.18);
  color: #ffeaea;
}

#editAddPane,
#editBondPane,
#editTransformPane {
  display: none;
  margin-top: 8px;
  border-top: 1px solid var(--vm-color-legacy-border-strong);
  padding-top: 8px;
}

#editAddPane.active,
#editBondPane.active,
#editTransformPane.active {
  display: block;
}

#editAdaptiveMenu {
  position: fixed;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 34;
  pointer-events: auto;
  max-width: min(260px, calc(100vw - 24px));
}

#editAdaptiveMenu[aria-hidden="false"] {
  display: flex;
}

.adaptiveEditItem {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 150px;
  padding: 6px 8px;
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 12px;
  background: rgba(48, 53, 61, 0.92);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  color: #f2f5fa;
  cursor: pointer;
  text-align: left;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.adaptiveEditItem:hover {
  border-color: rgba(145, 156, 176, 0.42);
  background: rgba(56, 62, 71, 0.96);
}

.adaptiveEditItem.active {
  border-color: rgba(122, 172, 255, 0.72);
  background: rgba(56, 76, 108, 0.95);
  box-shadow: 0 14px 30px rgba(18, 30, 54, 0.34);
}

#editAdaptiveAddAtomPopover,
#editAdaptiveAddFragmentPopover,
#editAdaptiveAddMoleculePopover,
#editAdaptiveTransformPopover {
  position: fixed;
  display: none;
  width: min(280px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 12px;
  background: rgba(48, 53, 61, 0.96);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 35;
}

#editAdaptiveAddAtomPopover[aria-hidden="false"],
#editAdaptiveAddFragmentPopover[aria-hidden="false"],
#editAdaptiveAddMoleculePopover[aria-hidden="false"],
#editAdaptiveTransformPopover[aria-hidden="false"] {
  display: block;
}

#bondOrderPopup {
  position: fixed;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 14px;
  background: rgba(48, 53, 61, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  color: #f2f5fa;
  z-index: 36;
  pointer-events: auto;
}

#bondOrderPopup[aria-hidden="false"] {
  display: flex;
}

#bondOrderPopupTitle {
  font-size: 11px;
  font-weight: 700;
  color: #f2f5fa;
}

#bondOrderPopupButtons {
  display: flex;
  align-items: center;
  gap: 8px;
}

#bondOrderPopupButtons button {
  appearance: none;
  border: 1px solid rgba(117, 129, 150, 0.28);
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  background: rgba(17, 24, 39, 0.9);
  color: #f2f5fa;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#bondOrderPopupButtons button:hover {
  background: rgba(24, 33, 51, 0.96);
  border-color: rgba(113, 168, 255, 0.64);
}

#bondOrderPopupButtons button.active {
  background: rgba(15, 23, 42, 0.98);
  border-color: rgba(53, 130, 246, 0.96);
  box-shadow: inset 0 0 0 1px rgba(103, 176, 255, 0.28);
}

#editAddAtomOperatorPanel,
#editAddMoleculeOperatorPanel {
  position: fixed;
  right: 16px;
  bottom: 24px;
  display: none;
  width: min(260px, calc(100vw - 24px));
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 12px;
  background: rgba(30, 34, 40, 0.96);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 35;
  overflow: hidden;
}

#editAddAtomOperatorPanel[aria-hidden="false"],
#editAddMoleculeOperatorPanel[aria-hidden="false"] {
  display: block;
}

#editAddAtomOperatorHeader,
#editAddMoleculeOperatorHeader {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: #f2f5fa;
  cursor: pointer;
  text-align: left;
}

#editAddAtomOperatorHeader:hover,
#editAddMoleculeOperatorHeader:hover {
  background: rgba(255, 255, 255, 0.03);
}

.editAddAtomOperatorTitle,
.editAddMoleculeOperatorTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.editAddAtomOperatorChevron,
.editAddMoleculeOperatorChevron {
  font-size: 12px;
  color: rgba(214, 221, 233, 0.86);
  width: 12px;
  flex: 0 0 auto;
}

.editAddAtomOperatorLabel,
.editAddMoleculeOperatorLabel {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  color: #f5f7fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#editAddAtomOperatorBody,
#editAddMoleculeOperatorBody {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  padding: 0 12px 12px;
  align-items: center;
}

#editAddAtomOperatorPanel[data-collapsed="true"] #editAddAtomOperatorBody,
#editAddMoleculeOperatorPanel[data-collapsed="true"] #editAddMoleculeOperatorBody {
  display: none;
}

.editAddAtomOperatorRowLabel {
  font-size: 11px;
  font-weight: 700;
  color: rgba(214, 221, 233, 0.78);
  text-align: left;
  min-width: 52px;
}

.editAddAtomOperatorCoord {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 8px;
  background: rgba(94, 100, 109, 0.9);
  color: #f2f5fa;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
}

.editAddAtomOperatorCoord:focus {
  outline: none;
  border-color: rgba(122, 172, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(122, 172, 255, 0.18);
}

.editAddAtomOperatorFoot {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 600;
  color: rgba(214, 221, 233, 0.72);
  padding-top: 2px;
}

.editAddMoleculeOperatorButtonRow {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  padding-top: 2px;
}

.editAddMoleculeOperatorButtonRow button {
  appearance: none;
  flex: 1 1 0;
  border: 1px solid rgba(117, 129, 150, 0.28);
  border-radius: 8px;
  background: rgba(94, 100, 109, 0.9);
  color: #f2f5fa;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.editAddMoleculeOperatorButtonRow button:hover {
  border-color: rgba(145, 156, 176, 0.42);
  background: rgba(104, 111, 121, 0.94);
}

#editAdaptiveAddAtomPopover #editAddAtomPane,
#editAdaptiveAddFragmentPopover #editAddFragmentPane,
#editAdaptiveAddMoleculePopover #editAddMoleculePane,
#editAdaptiveTransformPopover #editTransformPane {
  display: block;
}

#editAdaptiveAddAtomPopover label:first-child,
#editAdaptiveAddFragmentPopover label:first-child,
#editAdaptiveAddMoleculePopover label:first-child,
#editAdaptiveTransformPopover label:first-child {
  margin-top: 0;
}

.adaptiveEditItemBody {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.adaptiveEditItemTitleRow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.adaptiveEditItemLabel {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  color: #f5f7fb;
  white-space: nowrap;
}

.adaptiveEditItemMeta {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
  color: rgba(214, 221, 233, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adaptiveShortcutGroup {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.adaptiveShortcutKey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 24px;
  padding: 0;
  border-radius: 8px;
  background: rgba(187, 195, 208, 0.14);
  border: 1px solid rgba(166, 176, 191, 0.2);
  color: rgba(221, 227, 236, 0.82);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#editAddModeToggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

#editAddModeToggle button {
  appearance: none;
  border: 1px solid var(--vm-color-legacy-border-soft);
  background: var(--vm-color-legacy-dark-surface);
  color: var(--vm-color-legacy-text-on-dark);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}

#editAddModeToggle button.active {
  border-color: var(--vm-color-accent-primary);
  background: var(--vm-color-accent-primary-soft);
  color: #eef7ff;
}

#editAddAtomPane,
#editAddFragmentPane,
#editAddMoleculePane {
  display: none;
}

#editAddAtomPane.active,
#editAddFragmentPane.active,
#editAddMoleculePane.active {
  display: block;
}

#editAddPane label,
#editBondPane label,
#editTransformPane label {
  display: block;
  font-size: 12px;
  color: #a9bdd6;
  margin-bottom: 5px;
}

#editCleanupPane {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--vm-color-legacy-border-strong);
}

#editCleanupPane .title {
  display: block;
  font-size: 12px;
  color: #a9bdd6;
  margin-bottom: 6px;
  font-weight: 700;
}

#editCleanupControls {
  display: grid;
  gap: 6px;
}

#editCleanupControls label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #c8d8ec;
  font-size: 12px;
}

#editCleanupControls input[type="checkbox"] {
  margin: 0;
}

#editCleanupStrengthRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

#editCleanupStrength {
  flex: 1 1 auto;
  accent-color: var(--vm-color-accent-primary);
}

#editCleanupStrengthValue {
  min-width: 30px;
  text-align: right;
  font-size: 12px;
  color: #c8d8ec;
  font-variant-numeric: tabular-nums;
}

#editCleanupApplyBtn {
  appearance: none;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--vm-color-legacy-dark-surface);
  color: var(--vm-color-legacy-text-on-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#editAddSearch,
#editBondOrder,
#editBondAction,
#editTransformScope,
#editTransformMode {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--vm-color-legacy-muted-chip-3);
  color: var(--vm-color-legacy-text-on-dark);
}

#editFragmentSearch {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--vm-color-legacy-muted-chip-3);
  color: var(--vm-color-legacy-text-on-dark);
}

#editMoleculeSearch {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--vm-color-legacy-muted-chip-3);
  color: var(--vm-color-legacy-text-on-dark);
}

#editAddQuick,
#editBondQuick,
#editFragmentQuick,
#editMoleculeQuick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#editAddQuick button,
#editBondQuick button,
#editFragmentQuick button,
#editMoleculeQuick button {
  appearance: none;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--vm-color-legacy-dark-surface);
  color: var(--vm-color-legacy-secondary-active-fg);
  cursor: pointer;
}

#editAddQuick button.active,
#editBondQuick button.active,
#editFragmentQuick button.active,
#editMoleculeQuick button.active {
  border-color: var(--vm-color-accent-primary);
  box-shadow: 0 0 0 1px rgba(74, 163, 255, 0.35) inset;
}

#editAddCurrent,
#editBondCurrent,
#editFragmentCurrent,
#editMoleculeCurrent,
#editTransformCurrent {
  margin-top: 7px;
  font-size: 12px;
  color: #c8d8ec;
  min-height: 1.4em;
}

#editMoleculeAlign {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

#editMoleculeAlign button {
  appearance: none;
  border: 1px solid var(--vm-color-legacy-border-soft);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--vm-color-legacy-dark-surface);
  color: var(--vm-color-legacy-secondary-active-fg);
  cursor: pointer;
  min-width: 0;
  flex: 1 1 0;
}

#editSnapPane {
  margin-top: 8px;
  border-top: 1px solid var(--vm-color-legacy-border-strong);
  padding-top: 8px;
}

#editSnapPane .title {
  display: block;
  font-size: 12px;
  color: #a9bdd6;
  margin-bottom: 5px;
  font-weight: 700;
}

#editSnapHint {
  margin-top: 5px;
  font-size: 11px;
  color: #96adca;
}
