.editor-toolbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 10px;
  border: 1px solid rgba(16, 24, 32, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 18px 55px rgba(16, 24, 32, .18);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

body:not(.admin-mode) .editor-toolbar,
body:not(.admin-mode) .photo-editor,
body:not(.admin-mode) .background-editor,
body:not(.admin-mode) .edit-controls,
body:not(.admin-mode) .element-controls,
body:not(.admin-mode) .admin-text-resize-handle {
  display: none !important;
}

.editor-toolbar button,
.edit-controls button,
.element-controls button,
.photo-editor button,
.background-editor button {
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.editor-toolbar button:hover,
.edit-controls button:hover,
.element-controls button:hover,
.photo-editor button:hover,
.background-editor button:hover {
  color: #fff;
  background: var(--steel);
  border-color: var(--steel);
}

.editor-toolbar .active,
.photo-editor .primary,
.background-editor .primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.editor-hint {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.edit-mode [contenteditable="true"] {
  outline: 1px dashed rgba(195, 109, 47, .85);
  outline-offset: 3px;
  cursor: text;
}

.edit-controls,
.element-controls {
  position: absolute;
  z-index: 80;
  display: none;
  flex-wrap: wrap;
  gap: 5px;
  width: max-content;
  max-width: min(620px, calc(100vw - 34px));
  padding: 5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 30px rgba(16, 24, 32, .18);
  backdrop-filter: blur(8px);
}

.edit-controls {
  top: 10px;
  right: 10px;
}

.element-controls {
  top: 8px;
  left: 8px;
}

.edit-mode section > .edit-controls,
.edit-mode article > .edit-controls,
.edit-mode .editable-block > .edit-controls,
.edit-mode .editable-unit:hover > .element-controls,
.edit-mode .editable-unit:focus-within > .element-controls {
  display: flex;
}

.edit-mode section > .edit-controls,
.edit-mode article > .edit-controls,
.edit-mode .editable-block > .edit-controls {
  opacity: .92;
}

.edit-mode section:hover > .edit-controls,
.edit-mode article:hover > .edit-controls,
.edit-mode .editable-block:hover > .edit-controls {
  opacity: 1;
}

.control-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 3px 5px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.control-field input {
  width: 54px;
  min-height: 28px;
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #f7f9fb;
  font: inherit;
  text-align: center;
}

.editable-unit {
  position: relative;
}

.admin-text-resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  z-index: 85;
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 6px 18px rgba(16, 24, 32, .24);
  cursor: ew-resize;
  touch-action: none;
}

.admin-text-resize-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translate(-62%, -62%);
}

.edit-mode .custom-admin-text:hover > .admin-text-resize-handle {
  display: block;
}

.edit-mode .editable-unit:hover {
  box-shadow: 0 0 0 2px rgba(15, 96, 150, .34);
}

.admin-text-sized,
.admin-text-sized h1,
.admin-text-sized h2,
.admin-text-sized h3,
.admin-text-sized p,
.admin-text-sized li,
.admin-text-sized span {
  font-size: var(--admin-text-size, inherit) !important;
}

.element-controls .photo-action {
  display: inline-flex;
}

body.edit-mode main img {
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}

body.edit-mode main figure.admin-photo-frame,
body.edit-mode main .admin-photo-frame {
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

main .saved-photo-frame {
  position: relative;
  overflow: hidden !important;
}

body.edit-mode:not(.photo-scale-mode) main figure.admin-photo-frame:hover,
body.edit-mode:not(.photo-scale-mode) main .admin-photo-frame:hover,
body.edit-mode:not(.photo-scale-mode) main figure.admin-photo-frame:focus-within,
body.edit-mode:not(.photo-scale-mode) main .admin-photo-frame:focus-within,
body.edit-mode:not(.photo-scale-mode) main figure.editable-unit:hover,
body.edit-mode:not(.photo-scale-mode) main figure.editable-unit:focus-within {
  overflow: hidden !important;
  z-index: 90;
}

body.edit-mode main .admin-photo-frame > .element-controls,
body.edit-mode main .saved-photo-frame > .element-controls {
  left: 8px;
  right: 8px;
  width: auto;
  max-width: calc(100% - 16px);
  flex-wrap: wrap;
}

/* Keep every action visible inside the narrow portfolio cards. */
body.edit-mode main .kokil-portfolio-grid figure.editable-unit > .element-controls {
  left: 6px;
  right: 6px;
  width: auto;
  max-width: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
}

body.edit-mode main .kokil-portfolio-grid figure.editable-unit:hover > .element-controls,
body.edit-mode main .kokil-portfolio-grid figure.editable-unit:focus-within > .element-controls {
  display: grid;
}

body.edit-mode main .kokil-portfolio-grid figure.editable-unit > .element-controls button {
  min-width: 0;
  min-height: 30px;
  padding: 5px 6px;
  font-size: 11px;
  line-height: 1.1;
}

body.edit-mode main .kokil-portfolio-grid figure.editable-unit > .element-controls button:last-child {
  grid-column: 1 / -1;
}

body.edit-mode main figure.admin-photo-frame:active,
body.edit-mode main .admin-photo-frame:active {
  cursor: grabbing;
}

body.edit-mode main img:active {
  cursor: grabbing;
}

body.edit-mode main img.admin-photo-active {
  z-index: 3;
}

body.edit-mode main .admin-photo-frame-active {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, .18);
}

body.photo-scale-mode main .admin-photo-frame-active.admin-photo-frame-editing {
  z-index: 20;
}

body.photo-scale-mode main .admin-photo-frame-active.admin-photo-frame-editing img.admin-photo-active {
  position: relative;
  z-index: 21;
  box-shadow: none;
  max-width: 100%;
  max-height: 100%;
}

.photo-editor,
.background-editor {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 13, 18, .68);
}

.photo-editor.is-open,
.background-editor.is-open {
  display: flex;
}

.photo-editor-box,
.background-editor-box {
  width: min(620px, 100%);
  padding: 22px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .36);
}

.photo-editor-box h3,
.background-editor-box h3 {
  margin: 0 0 14px;
  font-size: 22px;
}

.photo-editor-box input,
.background-editor-box input[type="text"] {
  width: 100%;
  min-height: 46px;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
}

.photo-editor-file {
  display: block;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  cursor: pointer;
}

.photo-editor-file span {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.photo-editor-status {
  min-height: 20px;
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.photo-editor-status.is-error {
  color: #b42318;
}

.background-dim-field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  font-size: 13px;
  font-weight: 800;
}

.background-dim-field input {
  width: 100%;
}

.background-dim-field b {
  min-width: 42px;
  text-align: right;
}

.photo-editor.is-busy .photo-editor-box,
.background-editor.is-busy .background-editor-box {
  cursor: wait;
}

.photo-editor button:disabled,
.photo-editor input:disabled,
.background-editor button:disabled,
.background-editor input:disabled {
  opacity: .58;
  cursor: wait;
}

.photo-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 760px) {
  .editor-toolbar {
    right: 12px;
    left: 12px;
    bottom: 12px;
    flex-wrap: wrap;
    transform: none;
  }

  .editor-hint {
    width: 100%;
  }
}


/* Explicit text editing for the four LND process-card captions. */
body.edit-mode main [data-admin-editable-caption] {
  position: relative;
  z-index: 95;
  pointer-events: auto;
  user-select: text;
  cursor: text;
}



/* Independent LND editable captions: keep photo controls away from text. */
body.edit-mode main .lnd-card > figcaption[data-admin-editable-caption]{position:relative!important;z-index:120!important;pointer-events:auto!important;user-select:text!important;cursor:text!important;outline-offset:-3px}
body.edit-mode main .lnd-card > figcaption[data-admin-editable-caption]:hover{box-shadow:inset 0 0 0 2px rgba(243,107,33,.75)}
body.edit-mode main .lnd-card > figcaption[data-admin-editable-caption]:focus{outline:2px solid #f36b21!important;box-shadow:inset 0 0 0 2px rgba(255,255,255,.35)}

/* Keep the Equipment hero text above decorative layers while editing. */
body.admin-mode.edit-mode #equipment-page-hero .hero-copy,
body.admin-mode.edit-mode #equipment-page-hero .hero-actions,
body.admin-mode.edit-mode #equipment-page-hero .hero-tags {
  position: relative;
  z-index: 120;
  pointer-events: auto;
}

body.admin-mode.edit-mode #equipment-page-hero [data-admin-editable-text="equipment-hero"] {
  position: relative;
  z-index: 121;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text !important;
}

body.admin-mode.edit-mode #equipment-page-hero .hero-backdrop {
  pointer-events: none !important;
}
body.admin-mode.edit-mode #iron-castings [data-admin-editable-text="cast-iron-footer"] {
  position: relative;
  z-index: 5;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text !important;
}
body.admin-mode.edit-mode #equipment-supply .hero-copy,
body.admin-mode.edit-mode #equipment-supply .hero-tags{
  position:relative;
  z-index:120;
}