html.cms-loading body { opacity: 0; }
html.cms-ready body { opacity: 1; transition: opacity 120ms ease; }

[data-cms-hidden="true"] { display: none !important; }

.cms-admin-bar,
.cms-dialog,
.cms-block-tools,
.cms-text-tools,
.cms-toast {
  font-family: "Poppins", Arial, sans-serif;
}

.cms-admin-bar {
  position: sticky;
  z-index: 10000;
  top: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(330px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(16px, 2.5vw, 34px);
  border-top: 4px solid #e66f5c;
  border-bottom: 1px solid #ded7d1;
  background: rgba(255,255,255,.98);
  color: #332b27;
  box-shadow: 0 5px 20px rgba(51,43,39,.1);
  backdrop-filter: blur(14px);
}

.cms-admin-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.cms-admin-brand {
  width: 40px;
  height: 40px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 8px;
  background: #332b27;
  color: #fff;
  font-size: .92rem;
  font-weight: 800;
  letter-spacing: -.07em;
  line-height: 1;
  text-decoration: none;
}
.cms-admin-brand:hover { background: #e66f5c; color: #fff; }
.cms-admin-identity > span { display: grid; gap: 2px; color: #4b403a; font-size: .71rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.cms-admin-identity small { color: #9a8981; font-size: .52rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }

.cms-admin-navigation { min-width: 0; display: flex; align-items: center; gap: 8px; }
.cms-enquiries { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #814037; text-decoration: none; }
.cms-enquiry-badge { min-width: 22px; height: 22px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 999px; background: #e66f5c; color: #fff; font-size: .65rem; line-height: 1; }
.cms-enquiry-badge[hidden] { display: none; }
.cms-page-picker { min-width: 170px; max-width: 290px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; padding: 0 0 0 10px; border-left: 1px solid #e2dbd6; }
.cms-page-picker > span { color: #96857d; font-size: .56rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.cms-page-select,
.cms-admin-button,
.cms-tool-button {
  min-height: 40px;
  border: 1px solid #d8d0ca;
  border-radius: 7px;
  background: #fff;
  color: #493e38;
  font: 600 .82rem/1 "Poppins", Arial, sans-serif;
}

.cms-page-select { width: 100%; padding: 8px 34px 8px 11px; background-color: #faf8f6; }
.cms-admin-button,
.cms-tool-button { padding: 9px 14px; cursor: pointer; }
.cms-admin-button:hover,
.cms-tool-button:hover { border-color: #332b27; background: #332b27; color: #fff; }
.cms-enquiries:hover { border-color: #e66f5c; background: #fff1ee; color: #9f453a; }
.cms-publish:hover { border-color: #bc4e3f; background: #bc4e3f; color: #fff; }
.cms-signout:hover { border-color: #d8d0ca; background: #f3eeea; color: #332b27; }
.cms-view-live { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.cms-publish { border-color: #e66f5c; background: #e66f5c; color: #fff; font-weight: 700; }
.cms-signout { padding-inline: 11px; background: transparent; }
.cms-settings { padding-inline: 11px; }
.cms-admin-progress { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.cms-save-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #67a46d; box-shadow: 0 0 0 4px rgba(103,164,109,.12); }
.cms-save-state { color: #7f7069; font-size: .67rem; font-weight: 600; white-space: nowrap; }
.cms-admin-actions { display: flex; align-items: center; gap: 7px; }

.cms-admin [data-cms-text] { cursor: text; }
.cms-admin [data-cms-text]:hover,
.cms-admin [data-cms-text]:focus { outline: 2px dashed #bc4e3f; outline-offset: 3px; }
.cms-admin [data-cms-text][contenteditable="true"] { outline: 3px solid #bc4e3f; background: rgba(230,111,92,.16); }

.cms-admin [data-cms-image],
.cms-admin [data-cms-background] { cursor: pointer; }
.cms-admin [data-cms-image]:hover,
.cms-admin [data-cms-background]:hover { outline: 4px solid #e66f5c; outline-offset: -4px; }
.cms-admin [data-cms-block] { position: relative; }
.cms-admin [data-cms-block].cms-selected { outline: 3px solid #bc4e3f; outline-offset: 4px; }
.cms-admin [data-cms-hidden="true"] { display: revert !important; opacity: .35; }
.cms-admin [data-cms-hidden="true"]::after {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.65);
  color: #111;
  content: "Hidden when published";
  font: 700 .82rem "Poppins", Arial, sans-serif;
  pointer-events: none;
}

.cms-block-tools {
  position: fixed;
  z-index: 10001;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border-radius: 5px;
  background: #e66f5c;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.cms-block-tools[hidden] { display: none; }
.cms-text-tools {
  position: fixed;
  z-index: 10002;
  left: 50%;
  bottom: 16px;
  display: flex;
  gap: 7px;
  padding: 8px;
  border-radius: 5px;
  background: #e66f5c;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  transform: translateX(-50%);
}
.cms-text-tools[hidden] { display: none; }
.cms-tool-button { min-height: 36px; padding: 7px 11px; font-size: .73rem; }
.cms-text-tools .cms-tool-button[aria-pressed="true"] { background: #080808; color: #fff; }

.cms-dialog {
  width: min(520px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow-y: auto;
  border: 0;
  border-radius: 6px;
  background: #fff;
  color: #171717;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
}
.cms-dialog::backdrop { background: rgba(10,13,25,.72); }
.cms-dialog-form { display: grid; gap: 16px; padding: 24px; }
.cms-dialog h2 { margin: 0; color: #111; font: 700 1.25rem/1.2 "Poppins", Arial, sans-serif; }
.cms-dialog-note { margin: -6px 0 0; color: #666; font-size: .78rem; line-height: 1.5; }
.cms-dialog-field { display: grid; gap: 6px; }
.cms-dialog-field label { font-size: .76rem; font-weight: 700; }
.cms-dialog-field input,
.cms-dialog-field select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #a6a6a6; }
.cms-range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cms-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.cms-toast {
  position: fixed;
  z-index: 10003;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}

@media (max-width: 1100px) {
  .cms-admin-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 9px 14px;
    padding-block: 9px;
  }
  .cms-admin-identity { grid-column: 1; grid-row: 1; }
  .cms-admin-navigation { grid-column: 1 / 3; grid-row: 2; }
  .cms-admin-progress { grid-column: 2; grid-row: 1; justify-self: end; }
  .cms-admin-actions { grid-column: 3; grid-row: 1 / 3; display: grid; grid-template-columns: repeat(2, auto); }
  .cms-page-picker { width: min(290px, 40vw); max-width: none; }
  .cms-admin-button { padding-inline: 12px; }
}

@media (max-width: 860px) {
  .cms-admin-identity > span { display: none; }
  .cms-admin-actions { gap: 5px; }
  .cms-view-live, .cms-signout { display: none; }
  .cms-admin-actions { grid-template-columns: auto auto; }
  .cms-page-picker { width: min(260px, 42vw); }
  .cms-range-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html.cms-ready body { transition: none; }
}
