.cd-edit-wrap {
  position: relative;
  display: block;
  outline: 1px dashed transparent;
  outline-offset: 4px;
  transition: outline-color 0.2s ease;
}

/* Invisible hit bridge so cursor can reach the bar above without leaving :hover */
.cd-edit-wrap::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -2.75rem;
  height: 2.75rem;
  pointer-events: none;
}

.cd-edit-wrap:hover::before,
.cd-edit-wrap.is-editing::before {
  pointer-events: auto;
}

.cd-edit-wrap--abs {
  z-index: 0;
}

.cd-edit-wrap--abs::before {
  display: none;
}

.cd-edit-wrap--abs .cd-edit-bar {
  z-index: 5;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
  transform: none;
}

.cd-edit-wrap:hover,
.cd-edit-wrap.is-editing {
  outline-color: rgba(47, 111, 143, 0.55);
}

.cd-edit-bar {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  transform: translateY(calc(-100% - 6px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Fill the visual gap under the bar so hover doesn't drop mid-travel */
.cd-edit-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 6px;
}

.cd-edit-wrap:hover .cd-edit-bar,
.cd-edit-wrap.is-editing .cd-edit-bar,
.cd-edit-bar:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.cd-edit-bar [hidden] {
  display: none !important;
}

.cd-btn {
  appearance: none;
  border: 0;
  margin: 0;
  cursor: pointer;
  font: 600 0.72rem/1 Figtree, system-ui, sans-serif;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.55rem;
  background: #0c1a2a;
  color: #fff;
  border-radius: 2px;
  white-space: nowrap;
}

.cd-btn-save {
  background: #2f6f8f;
}

.cd-btn-cancel {
  background: #5a6b78;
}

.cd-btn-upload {
  display: inline-flex;
  align-items: center;
  background: #1a3348;
}

.cd-edit-wrap.is-editing [data-edit] {
  outline: 2px solid rgba(47, 111, 143, 0.35);
  outline-offset: 2px;
  min-width: 2rem;
}

.cd-edit-wrap.is-editing [data-edit][contenteditable='true'] {
  cursor: text;
  background: rgba(255, 255, 255, 0.55);
}

.cd-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 12px);
  z-index: 100;
  background: #0c1a2a;
  color: #fff;
  padding: 0.7rem 1rem;
  font: 600 0.9rem/1.2 Figtree, system-ui, sans-serif;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.cd-toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.cd-toast.is-error {
  background: #8b2e2e;
}

@media (max-width: 900px) {
  .cd-edit-wrap::before {
    display: none;
  }

  .cd-edit-bar {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    margin-bottom: 0.4rem;
    justify-content: flex-end;
  }

  .cd-edit-bar::after {
    display: none;
  }
}
