[data-section-removed] {
  display: none !important;
}

.section-editor {
  --section-editor-edge: 16px;
  --section-editor-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  position: fixed;
  z-index: 1200;
  right: max(var(--section-editor-edge), env(safe-area-inset-right, 0px));
  bottom: var(--section-editor-bottom);
  display: none;
  color: var(--rh-ink);
  font: 500 13px/1.4 var(--rh-sans);
}

body.dev-mode.dev-editing:not(.nav-drawer-open) .section-editor { display: block; }
.section-editor [hidden] { display: none !important; }

.section-editor button {
  appearance: none;
  margin: 0;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  cursor: pointer;
}

.section-editor button:focus-visible {
  outline: 2px solid var(--rh-cta);
  outline-offset: 2px;
}

.section-editor button:disabled {
  opacity: 0.35;
  cursor: default;
}

.section-editor .section-editor__toggle {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--rh-ink);
  border-radius: 999px;
  background: var(--rh-ink);
  color: #fff;
  box-shadow: 0 6px 18px rgba(36, 33, 30, 0.21);
  font-size: 11px;
  font-weight: 750;
}

.section-editor .section-editor__toggle[aria-expanded="true"] {
  border-color: var(--rh-cta);
  background: var(--rh-cta);
}

.section-editor__panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2 * var(--section-editor-edge)));
  max-height: min(580px, calc(100vh - 132px));
  max-height: min(580px, calc(100dvh - var(--section-editor-bottom) - 69px));
  overflow: hidden;
  border: 1px solid var(--rh-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 13px 46px rgba(36, 33, 30, 0.21);
}

.section-editor__header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 0;
}

.section-editor__title {
  margin: 0;
  font: 750 18px/1.2 var(--rh-display);
  letter-spacing: -0.015em;
}

.section-editor .section-editor__close {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--rh-surface-2);
  font-size: 19px;
}

.section-editor__hint {
  flex: none;
  margin: 4px 14px 11px;
  color: var(--rh-muted);
  font-size: 12px;
}

.section-editor__groups {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 4px 14px 12px;
  overflow: auto;
  overscroll-behavior: contain;
}

.section-editor__group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.section-editor__group legend {
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  color: var(--rh-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.section-editor__list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-editor__row {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 40px;
  gap: 4px;
  padding: 3px 4px;
  border: 1px solid var(--rh-line);
  border-radius: 8px;
  background: var(--rh-surface-2);
}

.section-editor .section-editor__grab {
  display: grid;
  place-items: center;
  grid-column: 1;
  width: 30px;
  height: 32px;
  padding: 0;
  border-radius: 5px;
  font-size: 18px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.section-editor .section-editor__grab:active { cursor: grabbing; }

.section-editor .section-editor__name {
  grid-column: 2;
  min-width: 0;
  padding: 5px 2px;
  border-radius: 4px;
  overflow-wrap: anywhere;
  text-align: start;
  font-size: 12px;
  font-weight: 650;
}

.section-editor .section-editor__name:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.section-editor__actions {
  display: flex;
  grid-column: 3;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.section-editor__actions button,
.section-editor__history button {
  min-width: 28px;
  min-height: 30px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}

.section-editor__actions button:hover:not(:disabled),
.section-editor__history button:hover:not(:disabled),
.section-editor .section-editor__grab:hover:not(:disabled) {
  background: var(--rh-surface);
}

.section-editor__locked {
  grid-column: 3;
  margin-inline: 5px;
  color: var(--rh-muted);
  font-size: 11px;
  white-space: nowrap;
}

.section-editor__row[data-removed] {
  border-style: dashed;
  background: #fff;
}

.section-editor__row[data-removed] .section-editor__name { color: var(--rh-muted); }
.section-editor__row.is-dragging { opacity: .55; }
.section-editor__row.drop-before::before,
.section-editor__row.drop-after::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset-inline: 1px;
  height: 3px;
  border-radius: 3px;
  background: var(--rh-cta);
  pointer-events: none;
}

.section-editor__row.drop-before::before { top: -3px; }
.section-editor__row.drop-after::after { bottom: -3px; }

.section-editor__history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 5px 13px;
  border-top: 1px solid var(--rh-line);
}

.section-editor__status {
  min-height: 18px;
  margin: 0;
  padding: 0 14px 9px;
  color: var(--rh-muted);
  font-size: 11px;
}

body.dev-mode.dev-editing [data-section-item] {
  scroll-margin-block-start: calc(var(--rh-bar-h, 64px) + 20px);
}

body.dev-mode.dev-editing .section-editor-highlight {
  outline: 2px solid var(--rh-cta);
  outline-offset: -2px;
}

/* Give the gallery grip its own spot above the existing row of controls. */
body.dev-mode.dev-editing .thumb-tools [data-thumb-drag] {
  position: absolute;
  display: grid;
  place-items: center;
  inset-block-end: calc(100% + 15px);
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--rh-line);
  border-radius: 5px;
  background: #fff;
  color: var(--rh-ink);
  font: 700 15px/1 var(--rh-sans);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

body.dev-mode.dev-editing .thumb-tools [data-thumb-drag]:active { cursor: grabbing; }
body.dev-mode.dev-editing .pdp-thumb.is-gallery-dragging { opacity: .55; }

body.dev-mode.dev-editing .pdp-thumb.is-drop-before::before,
body.dev-mode.dev-editing .pdp-thumb.is-drop-after::after {
  position: absolute;
  z-index: 6;
  inset-inline: 0;
  height: 4px;
  background: var(--rh-cta);
  pointer-events: none;
  content: "";
}

body.dev-mode.dev-editing .pdp-thumb.is-drop-before::before { top: 0; }
body.dev-mode.dev-editing .pdp-thumb.is-drop-after::after { bottom: 0; }

@media (max-width: 1024px) {
  body.dev-mode.dev-editing .pdp-thumb.is-drop-before::before,
  body.dev-mode.dev-editing .pdp-thumb.is-drop-after::after {
    inset: 0 auto 0 0;
    width: 4px;
    height: auto;
  }

  body.dev-mode.dev-editing .pdp-thumb.is-drop-after::after {
    inset-inline: auto 0;
  }
}

@media (max-width: 640px) {
  .section-editor {
    --section-editor-edge: 12px;
    --section-editor-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}
