.cms-editing {
  padding-top: 72px;
}

.cms-editor-bar {
  position: fixed;
  z-index: 10000;
  inset: 0 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px max(18px, calc((100vw - 1180px) / 2));
  background: #071f31;
  color: #fff;
  border-bottom: 4px solid #bd9144;
  box-shadow: 0 12px 34px rgba(7, 31, 49, 0.28);
  font-family: Arial, Helvetica, sans-serif;
}

.cms-editor-bar strong,
.cms-editor-bar span {
  display: block;
}

.cms-editor-bar strong { font-size: 0.95rem; }
.cms-editor-bar span { margin-top: 3px; color: #d9e3e9; font-size: 0.76rem; }
.cms-editor-actions { display: flex; align-items: center; gap: 12px; }
.cms-save-state { min-width: 74px; color: #e5c681 !important; text-align: right; font-weight: 800; }

.cms-done-button,
.cms-upload-button,
.cms-dialog-close {
  min-height: 42px;
  border: 1px solid #bd9144;
  border-radius: 2px;
  padding: 9px 16px;
  background: #bd9144;
  color: #071f31;
  font: 800 0.86rem/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.cms-editable-text,
.cms-editable-image {
  animation: cms-marching-ants 850ms steps(2, end) infinite;
  outline: 2px dashed #f3bd3e !important;
  outline-offset: 3px;
  cursor: text;
}

.cms-editable-text {
  min-width: 0.25em;
  border-radius: 1px;
}

.cms-editable-text:focus {
  outline: 3px solid #55b7ff !important;
  background: rgba(255,255,255,0.96);
  color: #071f31;
  box-shadow: 0 0 0 5px rgba(7,31,49,0.45);
}

.cms-editable-image {
  cursor: pointer;
}

.cms-editable-image:hover {
  filter: brightness(0.78);
}

.cms-editing .hero-wash { pointer-events: none; }

.cms-image-frame { position: relative !important; }
.cms-image-swap-button {
  position: absolute;
  z-index: 60;
  top: 8px;
  right: 8px;
  min-height: 36px;
  border: 2px solid #fff;
  border-radius: 2px;
  padding: 7px 11px;
  background: #071f31;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  font: 800 0.72rem/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.cms-image-swap-button:hover { background: #bd9144; color: #071f31; }
.cms-image-swap-button.cms-hero-swap { top: 86px; right: max(18px, calc((100% - 1180px) / 2)); }

@keyframes cms-marching-ants {
  0% { outline-color: #f3bd3e; outline-offset: 2px; }
  50% { outline-color: #168bce; outline-offset: 4px; }
  100% { outline-color: #f3bd3e; outline-offset: 2px; }
}

.cms-dialog[hidden] { display: none; }
.cms-dialog {
  position: fixed;
  z-index: 11000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 15, 24, 0.82);
  font-family: Arial, Helvetica, sans-serif;
}

.cms-dialog-panel {
  width: min(980px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  background: #f7f5f0;
  color: #10283a;
  border-top: 6px solid #bd9144;
  box-shadow: 0 24px 70px rgba(0,0,0,0.38);
}

.cms-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 20px;
  background: #071f31;
  color: #fff;
}

.cms-dialog-head h2 { margin: 0 0 4px; color: #fff; font: 700 1.65rem/1.1 Georgia, serif; }
.cms-dialog-head p { margin: 0; color: #d9e3e9; font-size: 0.9rem; }
.cms-dialog-close { min-width: 42px; padding: 8px; background: transparent; color: #fff; }

.cms-image-controls {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) 1fr 1fr;
  gap: 20px;
  align-items: end;
  padding: 22px 28px;
  border-bottom: 1px solid #d9d7cf;
}

.cms-image-preview {
  height: 150px;
  overflow: hidden;
  background: #dfe4e5;
  border: 1px solid #bd9144;
}

.cms-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.cms-control { display: grid; gap: 8px; font-size: 0.82rem; font-weight: 800; }
.cms-control input[type="text"] { height: 44px; padding: 0 12px; border: 1px solid #9eabb2; background: #fff; }
.cms-control input[type="range"] { width: 100%; accent-color: #8c6424; }
.cms-upload-row { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: #ebe6dc; }
.cms-upload-row input { width: auto; max-width: 100%; }
.cms-library { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 22px 28px 30px; }
.cms-library button { display: grid; grid-template-rows: 120px auto; gap: 8px; min-width: 0; padding: 7px; border: 2px solid transparent; background: #fff; color: #10283a; text-align: left; cursor: pointer; }
.cms-library button:hover,
.cms-library button:focus-visible { border-color: #bd9144; }
.cms-library img { width: 100%; height: 120px; object-fit: cover; background: #dfe4e5; }
.cms-library span { overflow: hidden; font-size: 0.76rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.cms-dialog-message { min-height: 22px; margin: 0; padding: 0 28px 20px; color: #8d2626; font-size: 0.86rem; font-weight: 800; }

@media (max-width: 760px) {
  .cms-editing { padding-top: 96px; }
  .cms-editor-bar { min-height: 88px; align-items: flex-start; padding: 10px 12px; }
  .cms-editor-bar span { max-width: 190px; }
  .cms-editor-actions { flex-direction: column; align-items: flex-end; gap: 5px; }
  .cms-done-button { min-height: 38px; padding: 8px 12px; }
  .cms-dialog { padding: 8px; }
  .cms-dialog-panel { max-height: calc(100vh - 16px); }
  .cms-dialog-head,
  .cms-image-controls,
  .cms-upload-row { padding-inline: 16px; }
  .cms-image-controls { grid-template-columns: 1fr; }
  .cms-library { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cms-editable-text,
  .cms-editable-image { animation: none; }
}

