:root {
  --cea-editor-toolbar-height: 0px;
}

body.editor-active {
  padding-top: var(--cea-editor-toolbar-height);
}

body.editor-dashboard-open {
  overflow: hidden;
}

body.editor-active .topbar {
  top: var(--cea-editor-toolbar-height);
}

body.editor-active .mobile-nav {
  top: var(--cea-editor-toolbar-height);
}

body.editor-active .page-loader {
  z-index: 2100;
}

body.editor-active main {
  position: relative;
}

.cea-editor-toolbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1650;
  background: linear-gradient(180deg, rgba(6, 8, 12, 0.97), rgba(6, 8, 12, 0.92));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(1.08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.cea-editor-toolbar__inner {
  width: min(1220px, calc(100% - 24px));
  margin: 0 auto;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 10px 0;
}

.cea-editor-toolbar__brand,
.cea-editor-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.cea-editor-toolbar__brand {
  min-width: 0;
}

.cea-editor-toolbar__badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(111, 230, 255, 0.18);
  background: rgba(111, 230, 255, 0.08);
  color: #6fe6ff;
  font-family: 'League Spartan', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.cea-editor-toolbar__title {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.cea-editor-toolbar__title strong {
  color: #f4f7fb;
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cea-editor-toolbar__title span {
  color: rgba(244, 247, 251, 0.66);
  font-size: 0.78rem;
  line-height: 1.45;
  max-width: 60ch;
}

.cea-editor-toolbar__status {
  min-height: 1.1em;
  color: rgba(244, 247, 251, 0.72);
  font-size: 0.78rem;
  justify-self: start;
}

.cea-editor-toolbar__status[data-tone='success'] {
  color: #9ff0b7;
}

.cea-editor-toolbar__status[data-tone='error'] {
  color: #ffb2b2;
}

.cea-editor-toolbar__status[data-tone='warning'] {
  color: #ffd08b;
}

.cea-editor-button,
.cea-editor-icon-button,
.cea-editor-menu-item {
  appearance: none;
  font: inherit;
}

.cea-editor-button,
.cea-editor-icon-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.cea-editor-button:hover,
.cea-editor-icon-button:hover,
.cea-editor-icon-button[aria-expanded='true'] {
  background: rgba(255, 255, 255, 0.12);
}

.cea-editor-button:disabled,
.cea-editor-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.cea-editor-button--primary {
  background: linear-gradient(135deg, #2f80ff, #0fb79d);
  border-color: transparent;
  box-shadow: 0 14px 28px rgba(22, 94, 186, 0.28);
}

.cea-editor-icon-button {
  width: 42px;
  padding: 0;
  justify-content: center;
}

.cea-editor-icon-button svg {
  width: 18px;
  height: 18px;
}

.cea-editor-menu {
  position: relative;
}

.cea-editor-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 270px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(14, 18, 25, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

:root[data-theme='light'] .cea-editor-menu__panel {
  background: rgba(255, 255, 255, 0.98);
}

.cea-editor-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
}

.cea-editor-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.cea-editor-dashboard {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 24px);
  background: rgba(6, 8, 12, 0.64);
  backdrop-filter: blur(14px) saturate(1.02);
}

.cea-editor-dashboard[hidden] {
  display: none;
}

.cea-editor-dashboard__sheet {
  width: min(1120px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  padding: 1.1rem;
  border-radius: 28px;
  background: rgba(12, 16, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 32px 72px rgba(0, 0, 0, 0.36);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
}

:root[data-theme='light'] .cea-editor-dashboard__sheet {
  background: rgba(248, 250, 252, 0.98);
}

.cea-editor-dashboard__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cea-editor-dashboard__header h2 {
  margin: 0.15rem 0 0;
}

.cea-editor-dashboard__lead {
  margin: 0.3rem 0 0;
  color: var(--muted);
  max-width: 50rem;
}

.cea-editor-dashboard__content {
  display: grid;
  gap: 1rem;
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
}

.cea-editor-dashboard__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.cea-editor-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.cea-editor-dashboard__notes {
  display: grid;
  gap: 0.9rem;
}

.cea-editor-dashboard__card {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

:root[data-theme='light'] .cea-editor-dashboard__card {
  background: rgba(15, 23, 42, 0.025);
}

.cea-editor-dashboard__card h3 {
  margin-bottom: 0.45rem;
  font-size: 1rem;
}

.cea-editor-dashboard__list {
  display: grid;
  gap: 0.45rem;
}

.cea-editor-dashboard__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 42px;
  padding: 0.72rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.cea-editor-dashboard__link:hover {
  border-color: rgba(111, 230, 255, 0.24);
  background: rgba(111, 230, 255, 0.08);
}

.cea-editor-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body.editor-active main [contenteditable='true'] {
  border-radius: 10px;
  outline: none;
  cursor: text;
  transition: box-shadow 160ms ease, background-color 160ms ease, transform 160ms ease;
}

body.editor-active main [contenteditable='true']:hover,
body.editor-active main [contenteditable='true']:focus,
body.editor-active main [contenteditable='true'].is-editor-focused {
  background: rgba(111, 230, 255, 0.07);
  box-shadow: 0 0 0 2px rgba(111, 230, 255, 0.2);
}

body.editor-active main img[data-editor-id] {
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 160ms ease, outline-color 160ms ease;
  outline: 1px dashed rgba(111, 230, 255, 0.28);
  outline-offset: 4px;
}

body.editor-active main img[data-editor-id]:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(111, 230, 255, 0.22);
}

body.editor-active main .cea-editor-image-surface {
  position: relative;
}

body.editor-active main .cea-editor-image-surface::after {
  content: 'Replace image';
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(7, 8, 10, 0.82);
  color: #ffffff;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

body.editor-active main .cea-editor-image-surface:hover::after {
  opacity: 1;
}

.cea-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 8, 12, 0.64);
  backdrop-filter: blur(16px) saturate(1.02);
}

.cea-editor-modal[hidden] {
  display: none;
}

.cea-editor-modal__card {
  width: min(560px, 100%);
  padding: 1.2rem;
  border-radius: 26px;
  background: rgba(11, 15, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 32px 72px rgba(0, 0, 0, 0.38);
}

:root[data-theme='light'] .cea-editor-modal__card {
  background: rgba(248, 250, 252, 0.98);
}

.cea-editor-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}

.cea-editor-modal__header h2 {
  margin: 0.1rem 0 0;
}

.cea-editor-modal__copy {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.cea-editor-modal__form {
  display: grid;
  gap: 0.8rem;
}

.cea-editor-modal__form label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--text);
}

.cea-editor-modal__form input,
.cea-editor-modal__form textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.78rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.cea-editor-modal__form input[type='file'] {
  padding: 0.55rem 0.7rem;
}

.cea-editor-modal__form input[type='file']::file-selector-button {
  margin-right: 0.85rem;
  padding: 0.58rem 0.9rem;
  border: 1px solid rgba(111, 230, 255, 0.2);
  border-radius: 10px;
  background: rgba(111, 230, 255, 0.1);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.cea-editor-modal__form input[type='file']::file-selector-button:hover {
  background: rgba(111, 230, 255, 0.16);
}

.cea-editor-modal__form textarea {
  min-height: 112px;
  resize: vertical;
}

.cea-editor-modal__note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.cea-editor-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.15rem;
}

@media (max-width: 980px) {
  body.editor-active {
    padding-top: calc(var(--cea-editor-toolbar-height) + 1px);
  }

  .cea-editor-toolbar__inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'brand actions'
      'status actions';
    row-gap: 0.4rem;
  }

  .cea-editor-toolbar__brand {
    grid-area: brand;
  }

  .cea-editor-toolbar__status {
    grid-area: status;
  }

  .cea-editor-toolbar__actions {
    grid-area: actions;
  }

  .cea-editor-dashboard__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body.editor-active .topbar {
    top: calc(var(--cea-editor-toolbar-height) + 1px);
  }

  body.editor-active .mobile-nav {
    top: calc(var(--cea-editor-toolbar-height) + 1px);
  }

  .cea-editor-toolbar__inner {
    width: calc(100% - 18px);
    grid-template-columns: 1fr;
    grid-template-areas:
      'brand'
      'actions';
    padding: 12px 0;
  }

  .cea-editor-toolbar__status {
    display: none;
  }

  .cea-editor-toolbar__actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.45rem;
  }

  .cea-editor-button {
    width: 100%;
    justify-content: center;
  }

  .cea-editor-menu__panel {
    min-width: min(290px, calc(100vw - 18px));
    max-width: calc(100vw - 18px);
  }

  .cea-editor-dashboard {
    padding: 12px;
  }

  .cea-editor-dashboard__sheet {
    max-height: min(88vh, 920px);
    padding: 0.95rem;
    border-radius: 22px;
    gap: 0.85rem;
  }

  .cea-editor-dashboard__header {
    flex-direction: column;
  }

  .cea-editor-dashboard__header .cea-editor-button {
    width: auto;
    align-self: flex-start;
  }

  .cea-editor-modal__header {
    flex-direction: column;
  }

  .cea-editor-modal__header .cea-editor-button {
    width: auto;
    align-self: flex-start;
  }

  .cea-editor-dashboard__content {
    gap: 0.85rem;
  }

  .cea-editor-dashboard__meta {
    gap: 0.45rem;
  }

  .cea-editor-dashboard__sheet,
  .cea-editor-modal__card {
    border-radius: 22px;
  }

  .cea-editor-modal__form input[type='file']::file-selector-button {
    margin-right: 0.65rem;
    padding: 0.52rem 0.82rem;
  }
}
