html.cms-off #cms-toggle, html.cms-off #cms-settings-toggle, html.cms-off .cms-edit-btn,
html.cms-off #cms-panel, html.cms-off #cms-site-settings { display: none !important; }

/* ── Edit mode toggle button ── */
#cms-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #243C4B;
  color: #F7F4EE;
  border: none;
  border-radius: 50px;
  padding: 11px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  letter-spacing: 0.02em;
  transition: background 0.2s;
}
#cms-toggle:hover { background: #1a2e3b; }
#cms-toggle.active { background: #6F8793; }

/* ── Section hover outline in edit mode ── */
body.cms-active [data-cms-section] {
  position: relative;
  outline: 2px dashed transparent;
  transition: outline-color 0.15s;
}

body.cms-active [data-cms-section]:hover {
  outline-color: rgba(111,135,147,0.5);
  cursor: pointer;
}

/* ── Section edit button that appears on hover ── */
.cms-edit-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: #243C4B;
  color: #F7F4EE;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.06em;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transition: background 0.15s;
}
.cms-edit-btn:hover { background: #6F8793; }
footer > .cms-edit-btn { background: #6F8793; }
#cms-blog-link { position: fixed; bottom: 76px; right: 24px; z-index: 9999; background: #F7F4EE; color: #243C4B; border-radius: 50px; padding: 9px 18px; font: 600 13px 'Inter', sans-serif; text-decoration: none; box-shadow: 0 4px 20px rgba(0,0,0,0.25); }
html:not(.cms-live) #cms-blog-link, html.cms-off #cms-blog-link { display: none; }
/* Hero sits under the fixed nav: drop its edit button below the nav bar */
.hero > .cms-edit-btn { top: calc(68px + 16px + env(safe-area-inset-top, 0px)); }

/* In edit mode, section buttons are always visible (touch screens have no hover) */
body.cms-active .cms-edit-btn {
  display: flex;
}

/* ── Sidebar panel ── */
#cms-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  height: 100vh;
  background: #1a2228;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -4px 0 40px rgba(0,0,0,0.4);
  font-family: 'Inter', sans-serif;
}

#cms-panel.open { right: 0; }

/* ── Panel header ── */
.cms-panel-header {
  background: #243C4B;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cms-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #F7F4EE;
}

.cms-panel-subtitle {
  font-size: 11px;
  color: rgba(247,244,238,0.4);
  margin-top: 2px;
}

.cms-close {
  background: none;
  border: none;
  color: rgba(247,244,238,0.4);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.cms-close:hover { color: #F7F4EE; background: rgba(255,255,255,0.06); }

/* ── Panel tabs ── */
.cms-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  background: #1e272e;
}

.cms-tab {
  flex: 1;
  padding: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(247,244,238,0.35);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s, border-bottom 0.15s;
  border-bottom: 2px solid transparent;
  text-transform: uppercase;
}

.cms-tab.active {
  color: #6F8793;
  border-bottom-color: #6F8793;
}

/* ── Panel body ── */
.cms-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.cms-panel-body::-webkit-scrollbar { width: 4px; }
.cms-panel-body::-webkit-scrollbar-track { background: transparent; }
.cms-panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.cms-tab-content { display: none; }
.cms-tab-content.active { display: block; }

/* ── Field group ── */
.cms-group {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.cms-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(247,244,238,0.28);
  margin-bottom: 14px;
}

/* ── Field row ── */
.cms-field {
  margin-bottom: 14px;
}

.cms-field:last-child { margin-bottom: 0; }

.cms-field-label {
  font-size: 12px;
  color: rgba(247,244,238,0.6);
  margin-bottom: 6px;
  display: block;
}

/* ── Inputs ── */
.cms-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 8px 10px;
  color: #F7F4EE;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.cms-input:focus { border-color: #6F8793; }

textarea.cms-input {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* ── Slider row ── */
.cms-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cms-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  outline: none;
}

.cms-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6F8793;
  cursor: pointer;
}

.cms-slider-val {
  font-size: 11px;
  color: #6F8793;
  font-weight: 600;
  min-width: 38px;
  text-align: right;
}

/* ── Color input ── */
.cms-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cms-color {
  width: 36px;
  height: 30px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 2px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.cms-color-hex {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 6px 10px;
  color: #F7F4EE;
  font-family: monospace;
  font-size: 12px;
  outline: none;
}

.cms-color-hex:focus { border-color: #6F8793; }

/* ── Toggle ── */
.cms-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.cms-switch {
  position: relative;
  width: 36px;
  height: 20px;
}

.cms-switch input { opacity: 0; width: 0; height: 0; }

.cms-switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.cms-switch-track::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: rgba(247,244,238,0.4);
  border-radius: 50%;
  transition: transform 0.2s;
}

.cms-switch input:checked + .cms-switch-track { background: #6F8793; }
.cms-switch input:checked + .cms-switch-track::before {
  transform: translateX(16px);
  background: #F7F4EE;
}

/* ── Panel footer ── */
.cms-panel-footer {
  padding: 14px 22px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: #1a2228;
}

.cms-btn-save {
  background: #6F8793;
  color: #F7F4EE;
  border: none;
  padding: 11px;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}
.cms-btn-save:hover { background: #7a93a0; }

.cms-btn-secondary {
  background: rgba(255,255,255,0.04);
  color: rgba(247,244,238,0.5);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 9px;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.cms-btn-secondary:hover { background: rgba(255,255,255,0.08); color: rgba(247,244,238,0.8); }

.cms-save-status {
  font-size: 11px;
  text-align: center;
  color: rgba(247,244,238,0.3);
  min-height: 14px;
}


/* Editor panels fit small screens; hide floating buttons while a panel is open */
@media (max-width: 520px) {
  #cms-panel { width: 100vw; right: -105vw; }
  #cms-site-settings { width: 100vw; left: -105vw; }
}
body:has(#cms-panel.open) #cms-toggle,
body:has(#cms-panel.open) #cms-settings-toggle,
body:has(#cms-site-settings.open) #cms-toggle { display: none; }

/* ── Site settings panel ── */
#cms-site-settings {
  position: fixed;
  top: 0;
  left: -380px;
  width: 360px;
  height: 100vh;
  background: #1a2228;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 4px 0 40px rgba(0,0,0,0.4);
  font-family: 'Inter', sans-serif;
}

#cms-site-settings.open { left: 0; }

#cms-settings-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  background: #243C4B;
  color: rgba(247,244,238,0.7);
  border: none;
  border-radius: 50px;
  padding: 11px 18px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: background 0.2s, color 0.2s;
}

#cms-settings-toggle:hover { background: #1a2e3b; color: #F7F4EE; }
body.cms-active #cms-settings-toggle { display: flex; }
body.cms-active #cms-blog-link { display: none; }
