/* Скрытое поле JSON блоков (форма конструктора) */
.be-blocks-json-field {
  display: none !important;
}

/* ─── Block Editor ──────────────────────────────────────────────────── */
/* Использует CSS-переменные из app.css (--color-*)                    */
/* Конструктор страниц: блок «Секция» — deploy marker                  */

.be-root {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-height: 500px;
}

/* ─── Canvas — центральная рабочая область ─────────────────────────── */
.be-canvas {
  flex: 1;
  min-width: 0;
  background: var(--color-surface, #fff);
  border: 2px dashed var(--color-border, #d0d5dd);
  border-radius: var(--radius, 8px);
  padding: 16px;
}

.be-canvas__inner {
  min-height: 200px;
  width: 100%;
  max-width: 96rem;
  margin-inline: auto;
}

/* Пустое состояние — большой + по центру */
.be-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
}

.be-empty-state__hint {
  font-size: 14px;
  color: var(--color-muted, #98a2b6);
}

/* Кнопка добавления блока — большой + в кружочке */
.be-add-btn-wrap {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.be-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 2px dashed var(--color-accent, #2b6cf5);
  border-radius: 50%;
  background: transparent;
  color: var(--color-accent, #2b6cf5);
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.be-add-btn:hover {
  background: var(--color-accent, #2b6cf5);
  color: var(--color-on-accent, #fff);
  border-style: solid;
  transform: scale(1.08);
}

.be-add-btn:active {
  transform: scale(0.95);
}

/* ─── Блок ─────────────────────────────────────────────────────────── */
.be-block {
  position: relative;
  padding: 14px 12px 14px 44px;
  margin-bottom: 8px;
  border: 2px solid transparent;
  border-radius: var(--radius, 6px);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.be-block:hover {
  border-color: var(--color-border, #d0d5dd);
  background: var(--color-surface-2, #f9fafb);
}

.be-block.is-selected {
  border-color: var(--color-accent, #2b6cf5);
  background: var(--color-accent, #2b6cf5);
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 8%, transparent);
}

.be-block--dragging {
  opacity: 0.4;
}

.be-block--drop-target {
  border-color: var(--color-accent, #2b6cf5);
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 12%, transparent);
}

/* Drag handle */
.be-block__drag-handle {
  position: absolute;
  left: 10px;
  top: 14px;
  font-size: 18px;
  color: var(--color-muted, #98a2b6);
  cursor: grab;
  user-select: none;
  line-height: 1;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.be-block:hover .be-block__drag-handle {
  opacity: 1;
}

.be-block__drag-handle:active {
  cursor: grabbing;
}

/* Инструменты блока (вверх/вниз/дублировать/удалить) */
.be-block__toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 2px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  padding: 2px;
  box-shadow: var(--shadow, 0 2px 8px rgba(0,0,0,0.08));
}

.be-block:hover .be-block__toolbar,
.be-block.is-selected .be-block__toolbar {
  display: flex;
}

.be-block__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text, #141922);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease;
  padding: 0;
  line-height: 1;
}

.be-block__btn:hover {
  background: var(--color-surface-2, #e4e9f2);
}

.be-block__btn--delete:hover {
  background: var(--color-danger, #c62828);
  color: #fff;
}

/* Содержимое блока */
.be-block__content {
  min-height: 24px;
}

.be-block__heading {
  margin: 0;
  line-height: 1.3;
}

.be-block__text {
  margin: 0;
  line-height: var(--be-text-line-height, 1.6);
}

.be-block__text .prose {
  max-width: 100%;
}

/* Типографика текстового блока: прямые дочерние элементы редактора */
.be-block__inner--text .be-text-canvas-editor,
.be-block__inner--text .be-text-canvas-editor > h1,
.be-block__inner--text .be-text-canvas-editor > h2,
.be-block__inner--text .be-text-canvas-editor > h3,
.be-block__inner--text .be-text-canvas-editor > h4,
.be-block__inner--text .be-text-canvas-editor > p,
.be-block__inner--text .be-text-canvas-editor > div,
.be-block__inner--text .be-text-canvas-editor > blockquote,
.be-public-block .prose,
.lesson-body-content .be-public-block .prose {
  line-height: var(--be-text-line-height, 1.6) !important;
}

.be-block__inner--text .be-text-canvas-editor > * + *,
.be-public-block .prose > * + *,
.lesson-body-content .be-public-block .prose > * + * {
  margin-top: var(--be-text-paragraph-gap, 8px) !important;
}

.be-block__text .prose p,
.be-text-canvas-editor.prose p,
.be-richtext__editor p,
.be-public-block .prose p,
.lesson-body-content .prose p {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.be-block__text .prose p + p,
.be-text-canvas-editor.prose p + p,
.be-richtext__editor p + p,
.be-public-block .prose p + p,
.lesson-body-content .prose p + p {
  margin-top: var(--be-text-paragraph-gap, 8px) !important;
}

/* Последний элемент в текстовом блоке не добавляет лишний отступ снизу (к padding блока) */
.be-block__text .prose > *:last-child,
.be-text-canvas-editor.prose > *:last-child,
.be-richtext__editor > *:last-child,
.be-public-block .prose > *:last-child,
.lesson-body-content .prose > *:last-child {
  margin-bottom: 0 !important;
}

/* Пустой хвостовой абзац в редакторе (курсор) — не создаёт зазор после текста */
.be-text-canvas-editor.prose > p:last-child:empty,
.be-text-canvas-editor.prose > p:last-child:has(> br:only-child),
.be-richtext__editor > p:last-child:empty,
.be-richtext__editor > p:last-child:has(> br:only-child) {
  margin-top: 0;
}

.be-block__text .prose h1,
.be-block__text .prose h2,
.be-block__text .prose h3,
.be-block__text .prose h4,
.be-text-canvas-editor.prose h1,
.be-text-canvas-editor.prose h2,
.be-text-canvas-editor.prose h3,
.be-text-canvas-editor.prose h4,
.be-richtext__editor h1,
.be-richtext__editor h2,
.be-richtext__editor h3,
.be-richtext__editor h4 {
  margin: 0.65em 0 0.35em;
  line-height: 1.25;
  font-weight: 700;
  color: inherit;
}

.be-block__text .prose h1:first-child,
.be-block__text .prose h2:first-child,
.be-block__text .prose h3:first-child,
.be-block__text .prose h4:first-child,
.be-text-canvas-editor.prose h1:first-child,
.be-text-canvas-editor.prose h2:first-child,
.be-text-canvas-editor.prose h3:first-child,
.be-text-canvas-editor.prose h4:first-child,
.be-richtext__editor h1:first-child,
.be-richtext__editor h2:first-child,
.be-richtext__editor h3:first-child,
.be-richtext__editor h4:first-child {
  margin-top: 0;
}

.be-block__text .prose h1,
.be-text-canvas-editor.prose h1,
.be-richtext__editor h1 { font-size: 2em; }

.be-block__text .prose h2,
.be-text-canvas-editor.prose h2,
.be-richtext__editor h2 { font-size: 1.5em; }

.be-block__text .prose h3,
.be-text-canvas-editor.prose h3,
.be-richtext__editor h3 { font-size: 1.25em; }

.be-block__text .prose h4,
.be-text-canvas-editor.prose h4,
.be-richtext__editor h4 { font-size: 1.1em; }

.be-root .be-block__content {
  width: 100%;
}

.be-root .be-block__shell {
  width: 100%;
  box-sizing: border-box;
}

.be-root .be-block__shell.be-block-pos--center {
  margin-left: auto;
  margin-right: auto;
}

.be-root .be-block__shell.be-block-pos--left {
  margin-left: 0;
  margin-right: auto;
}

.be-root .be-block__shell.be-block-pos--right {
  margin-left: auto;
  margin-right: 0;
}

.be-root .be-block__inner {
  width: 100%;
  box-sizing: border-box;
}

.be-root .be-block__inner--align-center {
  text-align: center;
}

.be-root .be-block__inner--align-right {
  text-align: right;
}

.be-root .be-block__inner--align-justify {
  text-align: justify;
}

/* Ширина в превью: классы на оболочке .be-block__shell (дублируют inline из JS) */
.be-root .be-block__shell.be-block-width--inherit,
.be-root .be-block__shell.be-block-width--normal {
  max-width: min(var(--container-max, 72rem), 100%);
}

.be-root .be-block__shell.be-block-width--wide {
  max-width: min(96rem, 100%);
}

.be-root .be-block__shell.be-block-width--full {
  max-width: 100%;
}

.be-root .be-block__shell.be-block-width--custom {
  max-width: var(--be-block-width-desktop, 100%);
}

@media (max-width: 1024px) {
  .be-root .be-block__shell.be-block-width--custom {
    max-width: var(--be-block-width-tablet, var(--be-block-width-desktop, 100%));
  }
}

@media (max-width: 640px) {
  .be-root .be-block__shell.be-block-width--custom {
    max-width: var(--be-block-width-mobile, var(--be-block-width-tablet, var(--be-block-width-desktop, 100%)));
  }
}

.be-responsive-width-fields {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--color-border, #d0d5dd);
}

/* Текстовый блок: ввод на канве, тулбар в сайдбаре */
.be-block__inner--text {
  /* overflow:hidden на inline-стилях ломает плавающую панель над выделением */
  overflow: visible !important;
}

.be-text-canvas-editor {
  min-height: 120px;
  outline: none;
  cursor: text;
  line-height: var(--be-text-line-height, 1.6) !important;
}

.be-text-canvas-editor:focus {
  outline: 2px solid color-mix(in srgb, var(--color-accent, #2b6cf5) 45%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

.be-public-block .prose,
.lesson-body-content .be-public-block .prose {
  line-height: var(--be-text-line-height, 1.6);
}

.be-richtext--toolbar-only {
  border: none;
  background: transparent;
  overflow: visible;
  margin-bottom: 12px;
}

.be-richtext--toolbar-only .be-richtext__toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Плавающая панель форматирования над выделением (блок «Текст» на канве) */
.be-richtext-float {
  position: fixed;
  z-index: 10050;
  display: none;
  pointer-events: none;
  max-width: calc(100vw - 24px);
  animation: be-float-toolbar-in 0.16s ease-out;
}

@keyframes be-float-toolbar-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.be-richtext-float.is-visible {
  display: block;
  pointer-events: auto;
}

.be-richtext--float {
  border: 1px solid color-mix(in srgb, var(--color-border, #d0d5dd) 55%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--color-surface, #fff) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  overflow: visible;
  padding: 6px;
}

.be-richtext--float .be-richtext__toolbar {
  position: static;
  border: none;
  background: transparent;
  max-width: min(520px, calc(100vw - 32px));
  padding: 2px 4px;
}

.be-richtext__toolbar--multi {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 0;
}

.be-richtext--float .be-richtext__toolbar--multi {
  gap: 4px;
}

.be-richtext__toolbar--multi.be-richtext__toolbar {
  border-bottom: none;
}

.be-richtext__toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.be-richtext--float .be-richtext__toolbar-row {
  gap: 3px;
}

.be-richtext__toolbar-row + .be-richtext__toolbar-row {
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--color-border, #d0d5dd) 45%, transparent);
}

.be-richtext--float .be-richtext__toolbar-row + .be-richtext__toolbar-row {
  margin-top: 2px;
  padding-top: 6px;
}

.be-richtext__toolbar-row--typography {
  gap: 10px;
  padding: 6px 8px;
  margin-top: 2px;
  border-top: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-surface-2, #f0f2f5) 65%, transparent);
}

.be-richtext--float .be-richtext__btn {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text, #141922);
  font-size: 13px;
  transition: background 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.be-richtext--float .be-richtext__btn:hover {
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 11%, var(--color-surface-2, #f0f2f5));
  border-color: transparent;
}

.be-richtext--float .be-richtext__btn:active {
  transform: scale(0.96);
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 18%, var(--color-surface-2, #f0f2f5));
  color: var(--color-text, #141922);
}

.be-richtext--float .be-richtext__btn--wide {
  min-width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.be-richtext--float .be-richtext__btn--heading {
  min-width: 36px;
  font-weight: 700;
}

.be-richtext__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.be-richtext__icon--color::after,
.be-richtext--float .be-richtext__btn--color::after,
.be-richtext--float .be-richtext__btn--bg::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.be-richtext--float .be-richtext__btn--color::after {
  background: currentColor;
}

.be-richtext--float .be-richtext__btn--bg::after {
  background: #fff59d;
}

.be-richtext--float .be-richtext__select,
.be-richtext--float .be-richtext__typography-select,
.be-richtext--float .be-richtext__typography-number {
  height: 34px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--color-border, #d0d5dd) 70%, transparent);
  border-radius: 9px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #141922);
  font-size: 12px;
  box-shadow: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.be-richtext--float .be-richtext__select:hover,
.be-richtext--float .be-richtext__select:focus,
.be-richtext--float .be-richtext__typography-select:hover,
.be-richtext--float .be-richtext__typography-select:focus,
.be-richtext--float .be-richtext__typography-number:hover,
.be-richtext--float .be-richtext__typography-number:focus {
  border-color: color-mix(in srgb, var(--color-accent, #2b6cf5) 55%, var(--color-border, #d0d5dd));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2b6cf5) 14%, transparent);
  outline: none;
}

.be-richtext--float .be-richtext__sep {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: color-mix(in srgb, var(--color-border, #d0d5dd) 55%, transparent);
}

.be-richtext__typography-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-muted, #5c6578);
  white-space: nowrap;
}

.be-richtext__typography-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 10px;
}

.be-richtext__typography-select,
.be-richtext__typography-number {
  height: 28px;
  padding: 2px 6px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  font-size: 12px;
  color: var(--color-text, #1a1a2e);
}

.be-richtext__typography-select {
  min-width: 56px;
  cursor: pointer;
}

.be-richtext__typography-number {
  width: 52px;
}

.be-richtext__btn--heading {
  min-width: 34px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.be-richtext__btn--heading[data-arg="h2"] {
  font-size: 13px;
}

.be-richtext__btn--heading[data-arg="h3"] {
  font-size: 12px;
}

/* ─── Видео блок ──────────────────────────────────────────────────── */
.be-block__video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background: var(--color-surface-2, #f0f2f5);
  border: 2px dashed var(--color-border, #d0d5dd);
  border-radius: var(--radius, 8px);
  gap: 10px;
  padding: 24px;
}

.be-block__video-placeholder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 14%, transparent);
  color: var(--color-accent, #2b6cf5);
  font-size: 24px;
}

/* ─── Картинка ────────────────────────────────────────────────────── */
.be-block__image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  background: var(--color-surface-2, #f0f2f5);
  border: 2px dashed var(--color-border, #d0d5dd);
  border-radius: var(--radius, 8px);
  gap: 10px;
  padding: 24px;
}

.be-block__image-placeholder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 14%, transparent);
  color: var(--color-accent, #2b6cf5);
  font-size: 28px;
}

.be-image-wrap {
  vertical-align: top;
}

.lesson-body-content .be-image-wrap,
.lesson-body .prose .be-image-wrap {
  display: inline-block !important;
}

.be-image {
  box-sizing: border-box;
}

.be-image-caption {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-muted, #5c6578);
  text-align: center;
}

.be-image-preview {
  position: relative;
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border, #d0d5dd);
  background: var(--color-surface, #fff);
}

.be-image-preview__img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: var(--color-surface-2, #f0f2f5);
}

.be-image-size-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
}

/* ─── Контейнер видео на канвасе ──────────────────────────────────── */
.be-video-container {
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.be-video-container[data-video-width],
.video-block-wrap[data-video-width] {
  width: auto;
  max-width: 100%;
  display: inline-block;
}

.be-video-container[data-video-width] .be-video-player,
.video-block-wrap[data-video-width] .video-block__video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.be-video-player {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

@media (max-width: 768px) {
  .be-video-container[data-video-width],
  .video-block-wrap[data-video-width] {
    width: 100% !important;
    display: block;
  }
}

/* ─── Современные поля формы для настроек видео ───────────────────── */
.be-video-settings {
  /* контейнер для настроек видео */
}

.be-settings-card {
  background: var(--color-surface-2, #f5f6f8);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--color-border, #e0e3e8);
}

/* Поле */
.be-field {
  margin-bottom: 16px;
}

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

.be-field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text, #141922);
  margin-bottom: 8px;
}

/* Обёртка инпута с иконкой */
.be-field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.be-field__icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  z-index: 1;
  opacity: 0.7;
}

.be-field__input {
  display: block;
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1.5px solid var(--color-border, #d0d5dd);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface, #fff);
  color: var(--color-text, #141922);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.be-field__input:focus {
  outline: none;
  border-color: var(--color-accent, #2b6cf5);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2b6cf5) 18%, transparent);
}

.be-field__input::placeholder {
  color: var(--color-muted, #98a2b6);
  font-size: 13px;
}

/* Upload область */
.be-field__upload-wrap {
  display: flex;
}

.be-field__upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1.5px dashed var(--color-accent, #2b6cf5);
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 6%, transparent);
  color: var(--color-accent, #2b6cf5);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.be-field__upload-btn:hover {
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 12%, transparent);
  border-style: solid;
}

.be-field__file-input {
  display: none;
}

.be-field__upload-icon {
  font-size: 18px;
}

/* Превью постера */
.be-poster-preview {
  position: relative;
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border, #d0d5dd);
  background: var(--color-surface, #fff);
}

.be-poster-preview__img {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
}

.be-poster-preview__clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  padding: 0;
  line-height: 1;
}

.be-poster-preview__clear:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Пустое состояние превью */
.be-poster-preview--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  border: 1.5px dashed var(--color-border, #d0d5dd);
  background: transparent;
  margin-top: 12px;
}

.be-poster-preview__icon {
  font-size: 28px;
  opacity: 0.5;
}

.be-poster-preview__hint {
  font-size: 13px;
  color: var(--color-muted, #98a2b6);
}

/* ─── Кнопка добавления блока перед текущим ────────────────────────── */
.be-block__add-before {
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px dashed var(--color-accent, #2b6cf5);
  border-radius: 50%;
  background: var(--color-surface, #fff);
  color: var(--color-accent, #2b6cf5);
  font-size: 18px;
  font-weight: 300;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  line-height: 1;
  z-index: 5;
}

.be-block:hover .be-block__add-before {
  opacity: 1;
}

.be-block__add-before:hover {
  background: var(--color-accent, #2b6cf5);
  color: var(--color-on-accent, #fff);
  border-style: solid;
  transform: translateX(-50%) scale(1.1);
}

/* ─── Сайдбар настроек (справа) ────────────────────────────────────── */
.be-sidebar {
  width: 360px;
  min-width: 300px;
  flex-shrink: 0;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: var(--radius, 8px);
  padding: 20px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.be-sidebar__inner {
  min-height: 100px;
}

.be-sidebar__empty {
  text-align: center;
  padding: 24px 0;
  color: var(--color-muted, #98a2b6);
  font-size: 13px;
}

.be-settings-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border, #d0d5dd);
}

.be-settings-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text, #141922);
}

.be-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.be-color-row input[type="color"] {
  flex: 0 0 48px;
}

.be-color-opacity {
  width: 64px !important;
  flex: 0 0 64px;
}

.be-color-opacity__label {
  font-size: 12px;
  color: var(--color-muted, #98a2b6);
  flex: 0 0 auto;
}

.be-settings-group {
  margin-bottom: 16px;
}

.be-settings-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted, #5c6578);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.be-settings-input[type="color"] {
  display: block;
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  cursor: pointer;
  background: var(--color-surface, #fff);
}
.be-settings-input[type="color"]:hover {
  border-color: var(--color-accent, #2b6cf5);
}

.be-settings-select,
.be-settings-textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface, #fff);
  color: var(--color-text, #141922);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.be-settings-select:focus,
.be-settings-textarea:focus {
  outline: none;
  border-color: var(--color-accent, #2b6cf5);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2b6cf5) 20%, transparent);
}

.be-settings-textarea {
  resize: vertical;
  min-height: 60px;
}

.be-settings-textarea--wide {
  min-height: 150px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* HTML-блок и редактор HTML-кода */
.be-html-source-editor {
  tab-size: 2;
}

.be-block__inner--html {
  min-height: 48px;
}

.be-html-canvas-preview {
  width: 100%;
}

.be-html-canvas-preview:empty::before {
  content: "HTML-блок пуст — добавьте код в настройках справа";
  display: block;
  color: var(--color-text-muted, #667085);
  font-size: 14px;
  font-style: italic;
}

/* ─── Модалка добавления блока ─────────────────────────────────────── */
.be-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.be-modal-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.be-modal {
  background: var(--color-surface, #fff);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.be-modal--small {
  max-width: 380px;
}

.be-modal--wide {
  max-width: 720px;
  width: 92vw;
}

.be-modal__body {
  padding: 0 24px 16px;
}

.be-modal__hint {
  margin: 0 0 10px;
}

.be-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 24px 24px;
}

.be-modal__title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #141922);
}

.be-modal__subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--color-muted, #5c6578);
}

.be-modal__types {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.be-modal__type-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 8px;
  background: var(--color-surface, #fff);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-size: 14px;
  font-family: inherit;
}

.be-modal__type-btn:hover {
  border-color: var(--color-accent, #2b6cf5);
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 6%, transparent);
  transform: translateX(4px);
}

.be-modal__type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 12%, transparent);
  color: var(--color-accent, #2b6cf5);
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}

.be-modal__type-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text, #141922);
}

.be-modal__type-desc {
  font-size: 12px;
  color: var(--color-muted, #5c6578);
  margin-top: 2px;
}

.be-settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text, #141922);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border, #d0d5dd);
}
.be-settings-section-title:first-of-type {
  margin-top: 0;
}

.be-spacing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.be-spacing-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.be-spacing-group__head .be-settings-label {
  margin: 0;
}

.be-spacing-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: var(--color-muted, #98a2b6);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.be-spacing-link:hover {
  border-color: var(--color-accent, #2b6cf5);
  color: var(--color-accent, #2b6cf5);
}

.be-spacing-link.is-linked {
  color: var(--color-accent, #2b6cf5);
  border-color: color-mix(in srgb, var(--color-accent, #2b6cf5) 35%, var(--color-border, #d0d5dd));
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 8%, var(--color-surface, #fff));
}

.be-spacing-link svg {
  width: 14px;
  height: 14px;
  display: block;
}

.be-spacing-link__slash {
  display: none;
}

.be-spacing-link.is-unlinked .be-spacing-link__slash {
  display: block;
}

.be-spacing-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.be-spacing-cell__label {
  font-size: 11px;
  color: var(--color-muted, #98a2b6);
  text-transform: lowercase;
}

.be-settings-number {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-surface, #fff);
  color: var(--color-text, #141922);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.be-settings-number:focus {
  outline: none;
  border-color: var(--color-accent, #2b6cf5);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2b6cf5) 20%, transparent);
}

.be-modal__close {
  display: block;
  width: 100%;
  text-align: center;
}

/* ─── Адаптивность ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .be-root {
    flex-direction: column;
  }

  .be-sidebar {
    width: 100%;
    min-width: 0;
    position: static;
  }
}

/* ─── Видео-блок с нативным постером ────────────────────────────────── */
.video-block-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.video-block__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ─── Кнопка (button block) ────────────────────────────────────────── */
.be-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  text-align: center;
}

.be-button:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

/* Основная */
.be-button--primary {
  background: var(--be-btn-bg, var(--color-accent, #2b6cf5));
  color: var(--be-btn-text, var(--color-on-accent, #fff));
}
.be-button--primary:hover {
  background: var(--be-btn-bg-hover, var(--color-accent-hover, #1e56cc));
  color: var(--be-btn-text-hover, var(--color-on-accent, #fff));
}

/* Вторичная */
.be-button--secondary {
  background: var(--be-btn-bg, var(--color-surface-2, #e4e9f2));
  color: var(--be-btn-text, var(--color-text, #141922));
}
.be-button--secondary:hover {
  background: var(--be-btn-bg-hover, #d0d6e3);
  color: var(--be-btn-text-hover, var(--color-text, #141922));
}

/* Контурная */
.be-button--outline {
  background: var(--be-btn-bg, transparent);
  color: var(--be-btn-text, var(--color-accent, #2b6cf5));
}
.be-button--outline:hover {
  background: var(--be-btn-bg-hover, color-mix(in srgb, var(--color-accent, #2b6cf5) 10%, transparent));
  color: var(--be-btn-text-hover, var(--color-accent, #2b6cf5));
}

/* Прозрачная */
.be-button--ghost {
  background: var(--be-btn-bg, transparent);
  color: var(--be-btn-text, var(--color-text, #141922));
}
.be-button--ghost:hover {
  background: var(--be-btn-bg-hover, var(--color-surface-2, #f0f2f5));
  color: var(--be-btn-text-hover, var(--color-text, #141922));
}

/* ─── RichText-редактор для блока "Текст" ──────────────────────────── */
.be-richtext {
  border: 1.5px solid var(--color-border, #d0d5dd);
  border-radius: 8px;
  overflow: visible;
  background: var(--color-surface, #fff);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.be-richtext:focus-within {
  border-color: var(--color-accent, #2b6cf5);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2b6cf5) 18%, transparent);
}

/* ─── Тулбар ───────────────────────────────────────────────────────── */
.be-richtext__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--color-surface-2, #f0f2f5);
  border-bottom: 1px solid var(--color-border, #d0d5dd);
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 10;
}

.be-richtext__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text, #141922);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  line-height: 1;
}

.be-richtext__btn:hover {
  background: var(--color-surface, #fff);
  border-color: var(--color-border, #d0d5dd);
}

.be-richtext__btn:active {
  background: var(--color-accent, #2b6cf5);
  color: var(--color-on-accent, #fff);
}

.be-richtext__btn--wide {
  min-width: auto;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.be-richtext__btn--color,
.be-richtext__btn--bg {
  position: relative;
}

.be-richtext__btn--color::after,
.be-richtext__btn--bg::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 1px;
}

.be-richtext__btn--color::after {
  background: currentColor;
}

.be-richtext__btn--bg::after {
  background: #ffff00;
}

.be-richtext__color-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.be-richtext__btn--color,
.be-richtext__btn--bg {
  position: relative;
}

.be-richtext__select {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 4px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #141922);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  height: 28px;
  line-height: 1;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  max-width: 110px;
}

.be-richtext__select--style {
  max-width: 132px;
}

.be-richtext__select:hover,
.be-richtext__select:focus {
  border-color: var(--color-accent, #2b6cf5);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent, #2b6cf5) 18%, transparent);
}

.be-richtext__sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--color-border, #d0d5dd);
  flex-shrink: 0;
}

/* ─── Редактор (contenteditable) ──────────────────────────────────── */
.be-richtext__editor {
  min-height: 150px;
  padding: 12px 14px;
  font-size: 15px;
  /* Используем переменную — иначе настройка «Строка» не видна */
  line-height: var(--be-text-line-height, 1.6);
  color: var(--color-text, #141922);
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.be-richtext__editor:empty::before {
  content: "Введите текст...";
  color: var(--color-muted, #98a2b6);
  pointer-events: none;
}

.be-richtext__editor blockquote,
.be-text-canvas-editor blockquote,
.be-section-preview__text blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--be-quote-border, var(--color-accent, #2b6cf5));
  background: var(--color-surface-2, #f0f2f5);
  border-radius: 0 6px 6px 0;
  color: var(--color-muted, #5c6578);
}

.be-richtext__editor ul,
.be-richtext__editor ol {
  margin: 6px 0;
  padding-left: 24px;
}

.be-richtext__editor li {
  margin-bottom: 3px;
}

.be-richtext__editor a {
  color: var(--color-accent, #2b6cf5);
  text-decoration: underline;
}

.be-richtext__editor a:hover {
  color: var(--color-accent-hover, #1e56cc);
}

/* ─── SortableJS ──────────────────────────────────────────────────── */
.be-block--sortable-ghost {
  opacity: 0.4;
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 12%, transparent);
  border: 2px dashed var(--color-accent, #2b6cf5);
  border-radius: var(--radius, 6px);
}

.be-block--sortable-chosen {
  border-color: var(--color-accent, #2b6cf5);
  background: color-mix(in srgb, var(--color-accent, #2b6cf5) 8%, transparent);
  box-shadow: 0 4px 16px rgba(43, 108, 245, 0.15);
}

.be-block--sortable-drag {
  opacity: 0.9;
  background: var(--color-surface, #fff);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  transform: rotate(2deg);
  z-index: 1000;
}

/* ─── Анимации ─────────────────────────────────────────────────────── */
@keyframes beBlockAppear {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.be-block {
  animation: beBlockAppear 0.2s ease;
}

/* Превью блока «Карточки» в конструкторе (app.css на панели не подключается) */
.be-cards-preview {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  align-items: stretch;
}

.be-cards-preview--cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.be-cards-preview--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.be-cards-preview--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.be-cards-preview--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.be-cards-preview--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.be-cards-preview__card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  height: 100%;
  border: 1px dashed var(--color-border, #d0d5dd);
  border-radius: 8px;
  padding: 0.75rem;
}

.be-cards-preview__media {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
}

.be-cards-preview__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.be-cards-preview__category {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.75);
}

.be-cards-preview__title {
  display: block;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.be-cards-preview__subtitle {
  margin: 0;
  font-size: 0.8rem;
}

.be-cards-preview__text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  min-height: 0;
}

@media (max-width: 900px) {
  .be-cards-preview--cols-3,
  .be-cards-preview--cols-4,
  .be-cards-preview--cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .be-cards-preview--cols-2,
  .be-cards-preview--cols-3,
  .be-cards-preview--cols-4,
  .be-cards-preview--cols-5 {
    grid-template-columns: 1fr;
  }
}
