/* Rich Editor (TipTap) — iOS-стиль под Фармгарант */

.re-root {
  --re-bg: var(--tg-theme-bg-color, #1c1c1e);
  --re-surface: var(--tg-theme-secondary-bg-color, #2c2c2e);
  --re-border: rgba(120,120,128,0.24);
  --re-text: var(--tg-theme-text-color, #fff);
  --re-hint: var(--tg-theme-hint-color, #8e8e93);
  --re-accent: #0a84ff;
  --re-active: rgba(10,132,255,0.18);
  display: flex;
  flex-direction: column;
  background: rgba(128,128,128,0.06);
  border: 1px solid var(--re-border);
  border-radius: 10px;
  overflow: hidden;
  /* (8595) заполняет .re-wrap; внутри неё .re-content flex:1 займёт ровно слот */
  flex: 1 1 auto;
  min-height: 100px;
  font-family: inherit;
  color: var(--re-text);
}
body[data-theme=light] .re-root {
  background: #fff;
}

/* ---- Toolbar ---- */
.re-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--re-surface);
  border-bottom: 1px solid var(--re-border);
  padding: 6px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
/* ПК: все инструменты одной строкой — обёртки прозрачны для flex */
.re-tb-primary, .re-tb-more { display: contents; }
.re-toolbar .re-more-btn { display: none; }

/* (8572/8576) Toggle режима редактирования — карандаш на горизонтали лейбла «Описание» */
/* (8595) .re-wrap должна заполнять flex-слот модалки, иначе .re-content
   распирается до max-height:60vh и вылезает из окна → двойной скроллбар. */
.re-wrap {
  position: relative;
  padding-top: 30px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.re-wrap.re-wrap-no-pad { padding-top: 0; }
.re-edit-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--re-border, rgba(120,120,128,0.24));
  border-radius: 7px;
  color: var(--re-hint, #8e8e93);
  cursor: pointer;
  z-index: 8;
}
.re-edit-toggle:hover { color: var(--re-text, #fff); background: rgba(120,120,128,0.12); }
.re-edit-toggle.on {
  color: var(--re-accent, #0a84ff);
  background: var(--re-active, rgba(10,132,255,0.18));
  border-color: var(--re-accent, #0a84ff);
}
/* (8597) Карандаш стоит инлайн сразу после слова «Описание» — без рамки,
   серый; при включённом редактировании — синий, без фоновой плашки */
.re-edit-toggle.re-edit-toggle-label {
  position: static;
  transform: none;
  width: 22px; height: 22px;
  margin-left: 6px;
  border: none;
  border-radius: 6px;
  vertical-align: middle;
}
.re-edit-toggle.re-edit-toggle-label:hover {
  background: transparent;
  color: var(--re-text, #fff);
}
.re-edit-toggle.re-edit-toggle-label.on {
  background: transparent;
  color: var(--re-accent, #0a84ff);
}
/* Read-only mode: toolbar скрыт целиком (никаких лишних строк) */
.re-readonly .re-toolbar { display: none !important; }
.re-readonly .re-content { cursor: default; }
.re-readonly .re-content .ProseMirror { caret-color: transparent; }
.re-readonly .re-content .ProseMirror :is(p,li,td,th,h1,h2,h3) { user-select: text; }
/* (8580) В режиме просмотра — клик по фото открывает lightbox */
.re-readonly .re-content img { cursor: zoom-in; }
/* (DVD-fix 2026-05-28) В режиме просмотра чекбоксы taskList не кликабельны.
   Клики по чекбоксу в read-only TipTap не должны менять документ — иначе
   при «Сохранить» это запишет фантомное состояние. */
.re-readonly .re-content ul[data-type="taskList"] li > label {
  cursor: default;
  pointer-events: none;
}
.re-readonly .re-content ul[data-type="taskList"] li > label input[type="checkbox"] {
  pointer-events: none;
  opacity: 0.7;
}

/* Разделитель групп инструментов */
.re-sep {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: rgba(120,120,128,0.55);
  margin: 0 5px;
  flex-shrink: 0;
  align-self: center;
}

.re-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--re-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: background 0.12s;
  flex-shrink: 0;
}
.re-btn:hover { background: rgba(120,120,128,0.18); }
.re-btn:active { background: rgba(120,120,128,0.28); }
.re-btn.on {
  background: var(--re-active);
  color: var(--re-accent);
}
.re-more-btn.on {
  background: var(--re-accent);
  color: #fff;
}

/* Кнопки с подписью / каретом / цветом */
.re-btn-wide, .re-btn-caret {
  width: auto;
  padding: 0 5px;
  gap: 2px;
}
.re-hd-tx { font-size: 12px; white-space: nowrap; }
.re-btn-color {
  width: auto;
  padding: 0 5px;
  flex-direction: column;
  gap: 1px;
}
.re-cbar {
  display: block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

/* ---- Поповеры (вне .re-root, в body) ---- */
.re-pop {
  position: fixed;
  z-index: 99999;
  background: #2c2c2e;
  color: #fff;
  border: 1px solid rgba(120,120,128,0.3);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.5);
  padding: 4px;
  font-family: inherit;
}
body[data-theme=light] .re-pop {
  background: #fff;
  color: #000;
  box-shadow: 0 12px 34px rgba(0,0,0,0.22);
}

/* Меню (стиль текста) */
.re-menu {
  display: flex;
  flex-direction: column;
  min-width: 190px;
}
.re-mi {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
}
.re-mi:hover { background: rgba(120,120,128,0.2); }
.re-mi-chk {
  width: 16px;
  flex-shrink: 0;
  display: inline-flex;
  color: #0a84ff;
}
.re-mi-h1 { font-size: 20px; font-weight: 700; }
.re-mi-h2 { font-size: 16px; font-weight: 600; }
.re-mi-h3 { font-size: 14px; font-weight: 600; }

/* Меню выравнивания — ряд иконок */
.re-menu-align {
  flex-direction: row;
  min-width: 0;
}
.re-mi-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  justify-content: center;
}
.re-mi-icon.on {
  background: rgba(10,132,255,0.18);
  color: #0a84ff;
}

/* Меню цвета */
.re-menu-color { min-width: 0; }
.re-mi-clear .re-x,
.re-mi-custom .re-pal {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  color: #8e8e93;
}
.re-swatches {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 6px 10px;
}
.re-sw {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(120,120,128,0.4);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
}
.re-sw:hover { transform: scale(1.12); }
.re-mi-custom { position: relative; }
.re-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
/* Кастомный color-picker (v=26, yougile-стиль) */
.re-cp {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 240px;
  box-sizing: border-box;
}
.re-cp-sv {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: 6px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.re-cp-sv-s { position: absolute; inset: 0; }
.re-cp-sv-v {
  position: absolute; inset: 0;
  background: linear-gradient(to top, #000, rgba(0,0,0,0));
}
.re-cp-sv-th {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.re-cp-hue {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.re-cp-hue-th {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,0.1);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.re-cp-hex {
  display: flex;
  align-items: center;
  gap: 4px;
}
.re-cp-hex-lbl {
  font-size: 11px;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}
.re-cp-hex-hash { color: #8e8e93; }
.re-cp-hex-input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(120,120,128,0.4);
  background: rgba(120,120,128,0.12);
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-transform: lowercase;
  outline: none;
  min-width: 0;
}
.re-cp-hex-input:focus {
  border-color: #0a84ff;
}
.re-cp-row {
  display: flex;
  gap: 8px;
}
.re-cp-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid rgba(120,120,128,0.4);
  background: rgba(120,120,128,0.12);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.re-cp-btn:hover { background: rgba(120,120,128,0.22); }
.re-cp-btn-ok { color: #34c759; }
.re-cp-btn-cancel { color: #ff453a; }

/* Диалог ссылки */
.re-pop-link { padding: 12px; }
.re-link-dlg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 290px;
  max-width: 80vw;
}
.re-link-text, .re-link-url {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid rgba(120,120,128,0.35);
  border-radius: 9px;
  background: rgba(120,120,128,0.12);
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.re-link-text:focus, .re-link-url:focus {
  outline: none;
  border-color: #0a84ff;
}
.re-link-row { display: flex; gap: 8px; }
.re-link-url { flex: 1; min-width: 0; }
.re-link-ok {
  padding: 9px 16px;
  border: none;
  border-radius: 9px;
  background: #0a84ff;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.re-link-ok:active { opacity: 0.8; }
.re-link-unset {
  margin-top: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255,59,48,0.4);
  background: rgba(255,59,48,0.12);
  color: #ff453a;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.re-link-unset:hover { background: rgba(255,59,48,0.2); }

/* Грид-пикер таблицы 10×10 */
.re-pop-table { padding: 10px; }
.re-table-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.re-tg-cells {
  display: grid;
  grid-template-columns: repeat(10, 18px);
  grid-auto-rows: 18px;
  gap: 3px;
}
.re-tg-cell {
  border: 1px solid rgba(120,120,128,0.45);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}
.re-tg-cell.on {
  background: #0a84ff;
  border-color: #0a84ff;
}
.re-tg-label {
  text-align: center;
  font-size: 13px;
  color: #8e8e93;
}

/* Индикатор загрузки файла */
.re-progress {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--re-accent);
  background: rgba(10,132,255,0.1);
}

/* ---- Content ---- */
.re-content {
  flex: 1 1 0;
  min-height: 80px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 400; /* p.1: убираем жирность, наследуемую от родителя (TG WebApp) */
  line-height: 1.5;
  outline: none;
  -webkit-overflow-scrolling: touch;
  /* (8595) единый стиль скроллбара + gutter резервирует место заранее,
     ширина .re-content не «прыгает» при появлении полосы → тулбар не переносится */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(128,128,128,0.4) transparent;
}
/* (8595) Единый тонкий скроллбар для всех прокручиваемых зон редактора */
.re-content::-webkit-scrollbar,
.re-content pre::-webkit-scrollbar,
.re-content table::-webkit-scrollbar { width: 8px; height: 8px; }
.re-content::-webkit-scrollbar-track,
.re-content pre::-webkit-scrollbar-track,
.re-content table::-webkit-scrollbar-track { background: transparent; }
.re-content::-webkit-scrollbar-thumb,
.re-content pre::-webkit-scrollbar-thumb,
.re-content table::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.4);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.re-content::-webkit-scrollbar-thumb:hover,
.re-content pre::-webkit-scrollbar-thumb:hover,
.re-content table::-webkit-scrollbar-thumb:hover {
  background: rgba(128,128,128,0.65);
  background-clip: padding-box;
}
/* p.3: selection полупрозрачный — чтобы при смене color/highlight цвет проступал */
.re-content ::selection { background: rgba(10,132,255,0.28); color: inherit; }
.re-content ::-moz-selection { background: rgba(10,132,255,0.28); color: inherit; }
.re-compact .re-content { max-height: 40vh; min-height: 64px; }
/* (8712/8714) Десктоп: все 22 кнопки в одной строке, мельче и без отступов.
   На мобильной (max-width:600px) — НЕ применяем; там работает общий мобильный паттерн
   (primary + «...» + re-tb-more.open ниже), такой же, как в форме «Новая заявка». */
@media (min-width: 601px) {
  .re-compact .re-toolbar {
    flex-wrap: nowrap;
    padding: 4px;
    gap: 1px;
  }
  .re-compact .re-tb-primary, .re-compact .re-tb-more { display: contents; }
  .re-compact .re-more-btn { display: none !important; }
  .re-compact .re-toolbar .re-btn { width: 28px; height: 28px; }
  .re-compact .re-toolbar .re-btn-wide { width: auto; padding: 0 6px; }
  .re-compact .re-toolbar .re-btn-caret { width: auto; padding: 0 2px; }
  .re-compact .re-toolbar .re-btn-color { width: auto; padding: 0 4px; }
  .re-compact .re-toolbar .re-sep { margin: 0 2px; }
  .re-compact .re-toolbar .re-btn svg { width: 16px; height: 16px; }
  /* (8738) ПК: растягиваем поле описания почти до низа, чтобы кнопка «Сохранить»
     уходила к панели вкладок, а не висела в середине экрана. */
  .re-compact .re-content { max-height: calc(100vh - 280px); min-height: 200px; }
}
/* «Новая заявка» — поле описания тянется по flex до кнопки (8616) */
#tf-desc .re-content { min-height: 220px; max-height: none; overflow: visible; flex: 0 0 auto; }

.re-content .ProseMirror {
  outline: none;
  min-height: 60px;
}
.re-content .ProseMirror > * + * { margin-top: 6px; }
.re-content p { margin: 0; }
.re-content h1 { font-size: 21px; font-weight: 700; margin: 10px 0 5px; }
.re-content h2 { font-size: 17px; font-weight: 600; margin: 8px 0 4px; }
.re-content h3 { font-size: 15px; font-weight: 600; margin: 6px 0 3px; }
.re-content ul, .re-content ol { padding-left: 20px; margin: 4px 0; }
.re-content ul[data-type="taskList"] {
  list-style: none;
  padding: 0;
}
.re-content ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0;
}
.re-content ul[data-type="taskList"] li > label {
  display: inline-flex;
  margin-top: 3px;
  cursor: pointer;
  user-select: none;
}
.re-content ul[data-type="taskList"] li > label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--re-accent);
  margin: 0;
}
.re-content ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.re-content ul[data-type="taskList"] li[data-checked="true"] > div { opacity: 0.6; }
.re-content ul[data-type="taskList"] li[data-checked="true"] > div p { text-decoration: line-through; }

.re-content a { color: var(--re-accent); text-decoration: underline; }
/* p.7: картинка не должна ломать ширину окна, max-width + height auto + box-sizing */
.re-content img {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
  border-radius: 8px;
  margin: 4px 0;
  cursor: pointer;
}
.re-content img.ProseMirror-selectednode {
  outline: 3px solid var(--re-accent);
  outline-offset: 1px;
}
.re-content hr {
  border: none;
  border-top: 3px solid var(--re-hint);
  border-radius: 2px;
  margin: 12px 0;
  opacity: 0.55;
  cursor: pointer;
}
/* p.5: при hover и выделении (node selection) — синий */
.re-content hr:hover { opacity: 1; border-top-color: var(--re-accent); }
.re-content hr.ProseMirror-selectednode {
  border-top-color: var(--re-accent);
  opacity: 1;
  outline: 2px solid var(--re-accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.re-content table {
  border-collapse: collapse;
  margin: 6px auto;
  table-layout: auto;
  width: auto;
  max-width: 100%;
}
/* отменяем фиксированные ширины colgroup, которые TipTap расставляет — иначе table-layout:auto не работает */
.re-content table colgroup col { width: auto !important; }
.re-content table td, .re-content table th {
  border: 1px solid #9aa0a8;
  background: #1d2933;
  color: #f0f1f3;
  padding: 6px 8px;
  min-width: 60px;
  vertical-align: top;
}
.re-content table th {
  background: #232f3b;
  font-weight: 600;
}
.re-content table td.selectedCell,
.re-content table th.selectedCell {
  position: relative;
}
.re-content table td.selectedCell::after,
.re-content table th.selectedCell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10,132,255,0.22);
  pointer-events: none;
  z-index: 2;
}
.re-content mark {
  background: rgba(241,196,15,0.4);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.re-content blockquote {
  border-left: 3px solid var(--re-accent);
  padding: 2px 0 2px 10px;
  margin: 6px 0;
  color: var(--re-hint);
}
.re-content code {
  background: rgba(120,120,128,0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}
.re-content pre {
  background: rgba(120,120,128,0.14);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
}
.re-content pre code { background: transparent; padding: 0; }

/* Placeholder */
.re-content .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--re-hint);
  pointer-events: none;
  height: 0;
}

/* ---- Mobile: 1-я строка + кнопка «...», доп. инструменты скрыты ---- */
@media (max-width: 600px) {
  /* Разделители-группы на мобильной не нужны */
  .re-sep { display: none; }
  /* Кнопки чуть крупнее под палец */
  .re-toolbar .re-btn { height: 34px; }
  /* Primary — отдельный flex-блок шириной (100% - место под «...»),
     чтобы кнопка «...» гарантированно помещалась в 1-й строке. */
  .re-tb-primary {
    display: flex;
    flex: 0 0 calc(100% - 34px);
    max-width: calc(100% - 34px);
    min-width: 0;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  /* Кнопка «...» гарантированно в 1-й строке (после primary) */
  .re-toolbar .re-more-btn { display: inline-flex; flex-shrink: 0; }
  /* Доп. инструменты: при раскрытии — отдельная строка ПОД primary */
  .re-tb-more { display: none; }
  .re-tb-more.open {
    display: flex;
    flex-basis: 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
  }
  .re-content { font-size: 15px; max-height: 50vh; }
}

/* ---- p.6: BubbleMenu таблицы + drag-handle ---- */
.re-tbl-bar {
  position: absolute;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--re-surface, #2c2c2e);
  border: 1px solid var(--re-border, rgba(120,120,128,0.24));
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.32);
  user-select: none;
}
body[data-theme=light] .re-tbl-bar { background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.re-tbl-bar button {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--re-text, #fff); cursor: pointer; padding: 0;
}
.re-tbl-bar button:hover { background: var(--re-active, rgba(10,132,255,0.18)); color: var(--re-accent, #0a84ff); }
.re-tbl-bar button svg { width: 16px; height: 16px; }
.re-tbl-sep {
  display: inline-block; width: 1px; height: 18px;
  background: var(--re-border, rgba(120,120,128,0.3));
  margin: 0 3px;
}
.re-tbl-drag {
  position: absolute;
  z-index: 6;
  display: none;
  align-items: center; justify-content: center;
  width: 28px; height: 14px;
  background: var(--re-accent, #0a84ff);
  color: #fff;
  border-radius: 5px;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.re-tbl-drag:active { cursor: grabbing; }
.re-tbl-drag svg { width: 14px; height: 14px; opacity: .95; }
.re-tbl-drop {
  position: absolute;
  z-index: 7;
  height: 3px;
  background: var(--re-accent, #0a84ff);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(10,132,255,0.55);
}

/* ---- п.5+6 (8544): hover-окантовка + кнопки «вставить строку выше/ниже» (yougile-стиль) ---- */
.re-hov-frame {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 2px solid #f5a623;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(245,166,35,0.25);
  transition: opacity .08s;
}
.re-hov-btn {
  position: absolute;
  z-index: 8;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f5a623;
  color: #1c1c1e;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.re-hov-btn:hover { background: #ffb945; }
.re-hov-btn svg { width: 14px; height: 14px; pointer-events: none; }
/* выделение через NodeSelection — оставляем синий outline (как было) */
.re-content .ProseMirror-selectednode { outline-offset: 0; }

/* ---- (8557) Унификация режима редактирования hr/img/table ---- */
/* Таблица: overlay-рамка вместо outline на table (ProseMirror перерисовывает <table> и затирает классы) */
.re-tbl-frame {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 2px solid var(--re-accent);
  border-radius: 4px;
  display: none;
}

/* HR в режиме редактирования: тащим саму линию. Курсор move на hover. */
.re-content hr { transition: outline-color .12s; }
.re-editing .re-content hr { cursor: move; }
.re-content.re-hr-dragging hr { opacity: 0.55; }
.re-hr-drop {
  position: absolute;
  z-index: 7;
  height: 3px;
  background: var(--re-accent, #0a84ff);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(10,132,255,0.55);
}

/* IMG: bubble-bar под выделенной картинкой (4 кнопки: ALT / inline / center / wrap) */
.re-img-bar {
  position: absolute;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--re-surface, #2c2c2e);
  border: 1px solid var(--re-border, rgba(120,120,128,0.24));
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.32);
  user-select: none;
}
body[data-theme=light] .re-img-bar { background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.re-img-bar button {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--re-text, #fff); cursor: pointer; padding: 0 6px;
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.re-img-bar button:hover { background: var(--re-active, rgba(10,132,255,0.18)); color: var(--re-accent, #0a84ff); }
.re-img-bar button.on { background: var(--re-active, rgba(10,132,255,0.18)); color: var(--re-accent, #0a84ff); }
.re-img-bar button svg { width: 16px; height: 16px; }
.re-img-bar i.re-img-sep {
  display: inline-block; width: 1px; height: 18px;
  background: var(--re-border, rgba(120,120,128,0.3));
  margin: 0 3px;
}

/* IMG: 4 угловых хэндла для ресайза (yougile-стиль) */
.re-img-rsz {
  position: absolute;
  z-index: 6;
  width: 12px; height: 12px;
  background: var(--re-accent, #0a84ff);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  display: none;
  touch-action: none;
}
.re-img-rsz-nw { cursor: nwse-resize; }
.re-img-rsz-ne { cursor: nesw-resize; }
.re-img-rsz-sw { cursor: nesw-resize; }
.re-img-rsz-se { cursor: nwse-resize; }

/* (8579) Картинка по умолчанию — целиком видна, центр */
.re-content img {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}
/* (8585) Положение картинки + обтекание текстом.
   left  → float:left, текст обтекает справа
   right → float:right, текст обтекает слева
   center/без align → блок по центру, текст только сверху/снизу */
.re-content img[data-align="left"] {
  float: left;
  margin: 4px 14px 6px 0;
}
.re-content img[data-align="right"] {
  float: right;
  margin: 4px 0 6px 14px;
}
.re-content img[data-align="center"] {
  display: block;
  clear: both;
  margin: 8px auto;
}
.re-content img:not([data-align]) {
  display: block;
  clear: both;
  margin: 8px auto;
}
