/* Editor chrome + login page. Подключается только сервером, не дизайном. */

body.has-editor {
  padding-bottom: 120px;
}

body.is-editing main [contenteditable="true"] {
  outline: 1px dashed rgba(239, 49, 36, 0.55);
  outline-offset: 2px;
  border-radius: 2px;
  transition: background 0.12s ease, outline-color 0.12s ease;
}

body.is-editing main [contenteditable="true"]:hover,
body.is-editing main [contenteditable="true"]:focus {
  outline-color: var(--red-2);
  background: rgba(239, 49, 36, 0.06);
}

body.is-editing main a {
  cursor: text;
}

.ed-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 200;
  width: min(880px, calc(100% - 32px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.ed-bar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 260px;
  min-width: 0;
}

.ed-badge {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red-2);
}

.ed-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.ed-status[data-kind="dirty"] {
  color: var(--red-2);
}

.ed-status[data-kind="error"] {
  color: var(--red-2);
}

.ed-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 1 auto;
}

.ed-btn {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.ed-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.ed-btn[hidden] {
  display: none;
}

.ed-btn-primary,
.ed-btn-save {
  background: var(--red-cta);
  border-color: transparent;
  color: #fff;
}

.ed-btn-primary:hover,
.ed-btn-save:hover {
  background: var(--red-cta-hover);
  border-color: transparent;
}

.ed-btn-save:disabled {
  opacity: 0.45;
  cursor: default;
}

.ed-btn-quiet {
  color: var(--muted);
}

.ed-drawer {
  position: fixed;
  top: 84px;
  right: 16px;
  bottom: 120px;
  z-index: 210;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100% - 32px));
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  visibility: hidden;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.2s;
}

.ed-drawer.is-open {
  visibility: visible;
  transform: none;
}

.ed-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ed-drawer-head b {
  font-size: 15px;
  font-weight: 500;
}

.ed-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.ed-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.ed-drawer-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.ed-drawer-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.ed-link-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding-right: 4px;
  overflow-y: auto;
}

.ed-link-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ed-link-row span {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ed-link-row input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.ed-link-row input:focus-visible {
  outline: 2px solid var(--red-2);
  outline-offset: 1px;
}

/* ---------- login ---------- */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-wrap {
  width: min(430px, 100%);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-card {
  padding: clamp(22px, 5vw, 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.login-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red-2);
}

.login-card h1 {
  margin-top: 10px;
  font-size: clamp(26px, 6vw, 32px);
  letter-spacing: -0.03em;
}

.login-card h1 + p,
.login-lede {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}

.login-error {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--red-line);
  border-radius: 8px;
  background: var(--red-dim);
  font-size: 13px;
  color: var(--red-2);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
}

.login-field span {
  font-size: 12px;
  color: var(--muted);
}

.login-field input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.login-field input:focus-visible {
  outline: 2px solid var(--red-2);
  outline-offset: 2px;
}

.login-submit {
  width: 100%;
  height: 46px;
  margin-top: 16px;
  border: 0;
  border-radius: 8px;
  background: var(--red-cta);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.login-submit:hover {
  background: var(--red-cta-hover);
}

.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.login-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.login-foot a {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

.login-foot a:hover {
  color: var(--text);
}

@media (max-width: 700px) {
  body.has-editor {
    padding-bottom: 170px;
  }

  .ed-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    transform: none;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }

  .ed-bar-head {
    flex: 0 0 auto;
  }

  .ed-bar-actions {
    gap: 6px;
  }

  .ed-btn {
    height: 38px;
    padding: 0 11px;
    font-size: 12px;
  }

  .ed-drawer {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 62vh;
    transform: translateY(calc(100% + 24px));
  }

  .ed-drawer.is-open {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ed-drawer,
  .ed-btn,
  body.is-editing main [contenteditable="true"] {
    transition: none !important;
  }
}
