.fedit {
  position: relative;
  /* Ensure CKEditor panels (dropdowns/balloons) overlay page content */
  --ck-z-default: 100000;
  --ck-z-panel: 100999;
  --ck-z-dialog: 101999;
}

.fedit__toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.fedit__toolbar button {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.fedit__toolbar button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fedit__srOnly {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.fedit__editOverlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.00));
  opacity: 0;
  transform: translateX(0.35rem);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 50;
}

.fedit:hover .fedit__editOverlay,
.fedit:focus-within .fedit__editOverlay,
.fedit.is-armed .fedit__editOverlay {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.fedit.is-busy .fedit__editOverlay,
.fedit.is-editing .fedit__editOverlay {
  display: none;
}

.fedit__editButton {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.fedit__editButton:hover {
  background: #fff;
}

.fedit__editIcon {
  color: rgba(0, 0, 0, 0.75);
}

.fedit.is-busy .fedit__toolbar button,
.fedit.is-busy input,
.fedit.is-busy textarea {
  pointer-events: none;
}

.fedit__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
  z-index: 2147483647;
}

.fedit__overlay__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  max-width: min(28rem, 90%);
  text-align: center;
}

.fedit__overlay__text {
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.8);
}

.fedit__spinner {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: rgba(0, 0, 0, 0.55);
  animation: fedit-spin 0.9s linear infinite;
}

@keyframes fedit-spin {
  to {
    transform: rotate(360deg);
  }
}

.fedit__form {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px dashed rgba(0, 0, 0, 0.25);
  border-radius: 0.6rem;
  background: rgba(0, 0, 0, 0.02);
  overflow: visible;
}

.fedit__form label {
  display: block;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
}

.fedit__form input[type="text"],
.fedit__form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.4rem;
  background: #fff;
}

.fedit__subheader {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.7);
}

.fedit__form textarea {
  min-height: 10rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
}

.fedit-small {
  font-size: 0.875em;
}

/* Responsive images in fedit output (avoid overflow and prevent upscaling) */
.fedit__bodytext img,
.fedit__bodytext figure.image img {
  max-width: 100% !important;
  height: auto !important;
  width: auto !important;
}

.fedit.is-editing .ck.ck-content img {
  max-width: 100% !important;
  height: auto !important;
  width: auto !important;
}

/* Simple lightbox for zoom-enabled RTE images (scoped to fedit) */
.fedit__lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
}

.fedit__lightboxBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.fedit__lightboxInner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.fedit__lightboxImg {
  max-width: min(100%, 1200px);
  max-height: calc(100vh - 4rem);
  width: auto;
  height: auto;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

.fedit__lightboxClose {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.fedit__lightboxClose:hover {
  background: rgba(0, 0, 0, 0.65);
}

html.fedit__lightboxOpen {
  overflow: hidden;
}

.fedit__editor {
  display: none;
  min-height: 12rem;
  overflow: visible;
}

.fedit__editor.is-active {
  display: block;
  position: relative;
  z-index: 100000;
}

/* Readability: code blocks in FE edit mode */
.fedit.is-editing .ck.ck-content pre,
.fedit.is-editing .ck.ck-content pre code {
  color: #000 !important;
}

.fedit.is-editing .ck.ck-content pre {
  background: #f3f3f3 !important;
}

/* Make CKEditor popups overlay the site (link UI, dropdown panels, etc.) */
.ck.ck-balloon-panel,
.ck.ck-dropdown__panel,
.ck.ck-dialog {
  z-index: 2147483647 !important;
}

/* Force overlay behavior even if site CSS resets positioning */
.ck.ck-dialog {
  position: fixed !important;
}

.ck.ck-balloon-panel,
.ck.ck-dropdown__panel {
  position: absolute !important;
}

/* Ensure dropdown panels are not clipped / behind editor chrome */
.fedit__editor .ck.ck-editor,
.fedit__editor .ck.ck-editor__top,
.fedit__editor .ck.ck-sticky-panel,
.fedit__editor .ck.ck-sticky-panel__content,
.fedit__editor .ck.ck-toolbar,
.fedit__editor .ck.ck-toolbar__items,
.fedit__editor .ck.ck-dropdown {
  overflow: visible;
}

.fedit__editor .ck.ck-editor__top,
.fedit__editor .ck.ck-toolbar,
.fedit__editor .ck.ck-sticky-panel__content {
  position: relative;
  z-index: 100001;
}

.fedit__editor .ck.ck-dropdown__panel,
.fedit__editor .ck.ck-balloon-panel,
.fedit__editor .ck.ck-dialog {
  z-index: 2147483647 !important;
}

/* Ensure the editable surface never overlays dropdown panels */
.fedit .ck.ck-editor__main,
.fedit .ck.ck-editor__editable,
.fedit .ck.ck-editor__editable_inline {
  position: relative;
  z-index: 1;
}

.fedit .ck.ck-editor__top,
.fedit .ck.ck-sticky-panel__content {
  position: relative;
  z-index: 2;
}

.fedit__status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.fedit__status--error {
  color: #b00020;
}

.fedit__status--success {
  color: #1b5e20;
}

