[data-page-editor][hidden],
[data-page-editor] [hidden] {
  display: none;
}

.page-editor-launch,
.page-editor-panel {
  position: fixed;
  z-index: 20;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}

.page-editor-launch {
  border: 1px solid #88dcff;
  box-shadow: 0 5px 20px #00123c40;
}

.page-editor-pencil::before {
  content: '\f303';
}

.page-editor-panel {
  width: min(390px, calc(100% - 36px));
  max-height: min(650px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  border: 1px solid #a9bad6;
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 16px 56px #00123c4d;
  overflow: hidden;
  font-size: 0.92rem;
}

.page-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 12px 19px;
  background: var(--night);
  color: var(--white);
}

.page-editor-header h2 {
  margin: 0;
  font-size: 1.36rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.page-editor-close {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid #7183ab;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 1.55rem;
  line-height: 1;
}

.page-editor-body {
  display: grid;
  gap: 11px;
  padding: 16px 19px;
  overflow: auto;
}

.page-editor-footer {
  display: grid;
  gap: 8px;
  flex: none;
  padding: 10px 19px 14px;
  border-top: 1px solid var(--line);
}

.page-editor-tools,
.page-editor-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 9px;
}

.page-editor-tools label {
  flex: 1 1 140px;
}

.page-editor-panel label {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-weight: 700;
}

.page-editor-panel input,
.page-editor-panel select,
.page-editor-panel textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #b1c2dd;
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

.page-editor-panel textarea {
  resize: vertical;
}

.page-editor-panel .button {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.page-editor-panel .button:disabled {
  opacity: 0.55;
  cursor: default;
}

.page-editor-hint,
.page-editor-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.page-editor-status:empty {
  display: none;
}

.page-copy-active [data-page-copy] {
  position: relative;
  outline: 1px dashed #608eb4;
  outline-offset: 3px;
  cursor: text;
}

.page-copy-active [data-page-copy]:hover,
.page-copy-active .page-copy-selected {
  outline: 2px solid var(--brand-cyan);
}

.page-copy-active [data-page-copy]::after {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  padding: 4px 5px;
  border-radius: 4px;
  color: var(--white);
  background: var(--blue-dark);
  content: '\f303';
  font: 900 0.65rem/1 'Font Awesome 7 Free';
  pointer-events: none;
  opacity: 0.7;
  transform: translateY(-70%);
}

.page-copy-active [data-page-copy]:hover::after,
.page-copy-active .page-copy-selected::after {
  opacity: 1;
}

@media (max-width: 640px) {
  .page-editor-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    max-height: 54dvh;
    border-radius: 14px 14px 0 0;
  }

  .page-editor-body {
    padding-block: 10px;
  }

  .page-editor-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .page-editor-hint {
    display: none;
  }

  .page-editor-panel textarea {
    height: 100px;
  }

  .page-editor-panel input,
  .page-editor-panel select,
  .page-editor-panel textarea {
    font-size: 1rem;
  }

  .page-copy-active [data-page-copy] {
    scroll-margin-bottom: 50dvh;
  }
}
