body:not(.is-edit-mode) .edit-panel,
body:not(.is-edit-mode) .edit-outline,
body:not(.is-edit-mode) .edit-badge {
  display: none;
}

body.is-edit-mode {
  cursor: default;
}

body.is-edit-mode [data-edit-selector] {
  outline: 1px solid transparent;
  outline-offset: 4px;
}

body.is-edit-mode [data-edit-selector]:hover {
  outline-color: rgba(92, 173, 255, 0.5);
}

.edit-outline {
  position: fixed;
  z-index: 10000;
  border: 1px solid #6bb6ff;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 12px 34px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.edit-outline::before,
.edit-outline::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 1px solid #6bb6ff;
  background: #050505;
}

.edit-outline::before {
  top: -4px;
  left: -4px;
}

.edit-outline::after {
  right: -4px;
  bottom: -4px;
}

.edit-badge {
  position: fixed;
  z-index: 10001;
  max-width: 280px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  background: rgba(7, 7, 7, 0.88);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 0;
  pointer-events: none;
}

.edit-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10002;
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(12, 12, 12, 0.9);
  color: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  overflow: hidden;
}

.edit-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.edit-panel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.edit-panel-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.edit-panel-title strong {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  line-height: 1;
}

.edit-panel-title em {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid rgba(107, 182, 255, 0.32);
  border-radius: 999px;
  color: rgba(154, 207, 255, 0.94);
  background: rgba(107, 182, 255, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.edit-panel-title span {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.54);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-panel-body {
  display: grid;
  gap: 14px;
  padding: 14px;
  overflow: auto;
}

.edit-fieldset {
  display: grid;
  gap: 8px;
}

.edit-fieldset > span {
  color: rgba(255, 255, 255, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.edit-control {
  display: grid;
  gap: 5px;
}

.edit-control label {
  color: rgba(255, 255, 255, 0.64);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  line-height: 1;
}

.edit-control input,
.edit-control select,
.edit-export {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.edit-control input,
.edit-control select {
  height: 30px;
  padding: 0 8px;
}

.edit-export {
  min-height: 118px;
  padding: 10px;
  resize: vertical;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-actions button,
.edit-close,
.edit-collapse {
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.edit-actions button {
  padding: 0 12px;
}

.edit-collapse {
  padding: 0 11px;
}

.edit-close {
  width: 30px;
  flex: 0 0 auto;
}

.edit-actions button:hover,
.edit-close:hover,
.edit-collapse:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (max-width: 800px) {
  .edit-panel {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: min(52svh, 460px);
    border-radius: 10px;
  }

  .edit-panel-header {
    padding: 11px 12px;
  }

  .edit-panel-body {
    max-height: calc(min(52svh, 460px) - 58px);
    padding: 12px;
  }

  .edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .edit-export {
    min-height: 78px;
  }

  body.is-edit-panel-collapsed .edit-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 58px;
  }

  body.is-edit-panel-collapsed .edit-panel-body {
    display: none;
  }

  body.is-edit-panel-collapsed .edit-panel-header {
    border-bottom: 0;
  }

  body.is-edit-panel-collapsed .edit-panel-title {
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 8px;
  }

  body.is-edit-panel-collapsed .edit-panel-title span {
    max-width: 128px;
  }
}
