/* =============================================================
   Дизайн-токены Editor Studio

   Один набор переменных на весь редактор: цвет, типографика, отступы,
   радиусы, тени. Страницы и компоненты берут только токены — поэтому
   правка здесь меняет вид всех вкладок сразу.
   ============================================================= */

:root,
:root[data-editor-theme="dark"],
.editor-theme[data-editor-theme="dark"]{
  /* Поверхности: фон → панель → поле. Разница в 2–3% яркости, чтобы
     вложенные блоки читались без тяжёлых рамок и теней. */
  --editor-bg:#0a0a0c;
  --editor-surface:#121216;
  --editor-surface-alt:#141419;
  --editor-surface-2:#1a1a21;
  --editor-panel:#121216;

  --editor-border:#232329;
  --editor-line:rgba(255,255,255,.07);
  --editor-line-strong:rgba(255,255,255,.13);

  /* Акцент один — синий. Бирюзовый остаётся «вторым» для графиков и метrik. */
  --editor-primary:#818cf8;
  --editor-secondary:#a78bfa;
  --editor-accent:#5cc6b0;
  --editor-danger:#f2727f;
  --editor-warning:#f0b464;
  --editor-success:#4fbe8b;

  --editor-text:#eceef2;
  --editor-text-muted:#9ba1ad;
  --editor-text-strong:#ffffff;

  --editor-font:system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
  --editor-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;
  --editor-color-scheme:dark;

  /* Типографическая шкала: 11 / 12.5 / 13.5 / 15 / 22 */
  --editor-text-xs:11px;
  --editor-text-sm:12.5px;
  --editor-text-md:13.5px;
  --editor-text-lg:15px;
  --editor-text-xl:22px;

  /* Шаг отступов */
  --editor-gap-1:4px;
  --editor-gap-2:8px;
  --editor-gap-3:12px;
  --editor-gap-4:16px;
  --editor-gap-5:24px;
  --editor-gap-6:32px;

  /* Радиусы */
  --editor-radius-xs:6px;
  --editor-radius-sm:8px;
  --editor-radius-md:10px;
  --editor-radius-lg:14px;
  --editor-radius:12px;

  /* Вторичные поверхности следуют за главным акцентом: при смене цвета вся
     палитра редактора остаётся одной гаммы, а не «синие теги + зелёный акцент». */
  --editor-bg-gradient-1:color-mix(in srgb, var(--editor-primary) 10%, transparent);
  --editor-bg-gradient-2:rgba(92,198,176,.07);
  --editor-bg-gradient-3:rgba(167,139,250,.05);

  --editor-input-bg:#0e0e12;
  --editor-panel-bg:#121216;
  --editor-field-bg:transparent;
  --editor-field-border:transparent;
  --editor-soft-bg:rgba(255,255,255,.028);
  --editor-soft-bg-strong:rgba(255,255,255,.055);
  --editor-soft-border:rgba(255,255,255,.07);
  --editor-soft-border-strong:rgba(255,255,255,.16);
  --editor-light-bg:rgba(255,255,255,.04);
  --editor-light-border:rgba(255,255,255,.09);
  --editor-light-hover:rgba(255,255,255,.07);

  --editor-row-bg:transparent;
  --editor-row-hover-bg:rgba(255,255,255,.04);
  --editor-row-hover-border:transparent;
  --editor-row-active-bg:color-mix(in srgb, var(--editor-primary) 16%, transparent);
  --editor-row-active-border:color-mix(in srgb, var(--editor-primary) 45%, transparent);

  --editor-button-secondary-bg:rgba(255,255,255,.05);
  --editor-button-secondary-border:rgba(255,255,255,.10);
  --editor-button-secondary-hover-bg:rgba(255,255,255,.09);
  --editor-icon-btn-bg:rgba(255,255,255,.05);
  --editor-icon-btn-border:rgba(255,255,255,.10);
  --editor-icon-btn-hover-bg:rgba(255,255,255,.09);

  --editor-tag-bg:color-mix(in srgb, var(--editor-primary) 14%, transparent);
  --editor-tag-border:color-mix(in srgb, var(--editor-primary) 26%, transparent);
  --editor-tag-hover-bg:color-mix(in srgb, var(--editor-primary) 20%, transparent);
  --editor-tag-hover-border:color-mix(in srgb, var(--editor-primary) 40%, transparent);
  --editor-badge-bg:rgba(255,255,255,.05);
  --editor-badge-border:rgba(255,255,255,.12);

  --editor-dropdown-bg:#1a1a21;
  --editor-dropdown-border:rgba(255,255,255,.12);
  --editor-dropdown-shadow:0 16px 40px rgba(0,0,0,.45);

  --editor-toolbar-bg:rgba(18,18,22,.94);
  --editor-toolbar-bg-2:rgba(18,18,22,.86);
  --editor-toolbar-border:rgba(255,255,255,.09);
  --editor-toolbar-shadow:0 10px 30px rgba(0,0,0,.30);

  --editor-scrollbar-track:transparent;
  --editor-scrollbar-thumb:rgba(255,255,255,.14);
  --editor-scrollbar-thumb-hover:rgba(255,255,255,.24);

  --editor-shell-bg:var(--editor-surface);
  --editor-shell-sidebar-bg:rgba(255,255,255,.014);
  --editor-shell-main-bg:transparent;

  --editor-font-size:14px;
  --editor-line-height:1.5;
  --editor-control-h:38px;
  --editor-space:14px;
  --editor-space-sm:10px;
  --editor-icon-size:18px;
  --editor-icon-bg:color-mix(in srgb, var(--editor-primary) 18%, transparent);
  --editor-icon-color:#c9ceff;
  --editor-focus-ring:color-mix(in srgb, var(--editor-primary) 32%, transparent);

  /* Тени только там, где блок действительно «висит» над страницей:
     модалки, выпадашки, тосты. Карточки и поля живут на волосяных рамках. */
  --editor-shadow-xs:0 1px 2px rgba(0,0,0,.20);
  --editor-shadow-sm:0 4px 12px rgba(0,0,0,.22);
  --editor-shadow-md:0 10px 28px rgba(0,0,0,.30);
  --editor-shadow-lg:0 24px 64px rgba(0,0,0,.45);
  --editor-elevated-bg:var(--editor-surface-2);
  --editor-elevated-border:var(--editor-line-strong);
  --editor-panel-glow:0 0 0 1px transparent;
  --editor-input-hover-bg:#141419;
  --editor-disabled-opacity:.5;
}

:root[data-editor-theme="light"],
.editor-theme[data-editor-theme="light"]{
  --editor-bg:#f3f5f9;
  --editor-surface:#ffffff;
  --editor-surface-alt:#fbfcfe;
  --editor-surface-2:#f5f8fc;
  --editor-panel:#ffffff;

  --editor-border:#dde3ec;
  --editor-line:rgba(16,23,34,.08);
  --editor-line-strong:rgba(16,23,34,.14);

  --editor-primary:#4f46e5;
  --editor-secondary:#7c5cd6;
  --editor-accent:#1f9e86;
  --editor-danger:#cf4d5b;
  --editor-warning:#b97a25;
  --editor-success:#1f8f5f;

  --editor-text:#101722;
  --editor-text-muted:#5f6b7d;
  --editor-text-strong:#000000;
  --editor-color-scheme:light;

  --editor-bg-gradient-1:color-mix(in srgb, var(--editor-primary) 7%, transparent);
  --editor-bg-gradient-2:rgba(31,158,134,.05);
  --editor-bg-gradient-3:rgba(124,92,214,.04);

  --editor-input-bg:#ffffff;
  --editor-panel-bg:#ffffff;
  --editor-field-bg:transparent;
  --editor-field-border:transparent;
  --editor-soft-bg:rgba(16,23,34,.03);
  --editor-soft-bg-strong:rgba(16,23,34,.055);
  --editor-soft-border:rgba(16,23,34,.10);
  --editor-soft-border-strong:rgba(16,23,34,.18);
  --editor-light-bg:rgba(16,23,34,.04);
  --editor-light-border:rgba(16,23,34,.10);
  --editor-light-hover:rgba(16,23,34,.065);

  --editor-row-bg:transparent;
  --editor-row-hover-bg:rgba(16,23,34,.04);
  --editor-row-hover-border:transparent;
  --editor-row-active-bg:color-mix(in srgb, var(--editor-primary) 12%, transparent);
  --editor-row-active-border:color-mix(in srgb, var(--editor-primary) 40%, transparent);

  --editor-button-secondary-bg:#ffffff;
  --editor-button-secondary-border:rgba(16,23,34,.14);
  --editor-button-secondary-hover-bg:#f3f6fb;
  --editor-icon-btn-bg:#ffffff;
  --editor-icon-btn-border:rgba(16,23,34,.14);
  --editor-icon-btn-hover-bg:#f3f6fb;

  --editor-tag-bg:color-mix(in srgb, var(--editor-primary) 10%, transparent);
  --editor-tag-border:color-mix(in srgb, var(--editor-primary) 22%, transparent);
  --editor-tag-hover-bg:color-mix(in srgb, var(--editor-primary) 15%, transparent);
  --editor-tag-hover-border:color-mix(in srgb, var(--editor-primary) 32%, transparent);
  --editor-badge-bg:rgba(16,23,34,.04);
  --editor-badge-border:rgba(16,23,34,.12);

  --editor-dropdown-bg:#ffffff;
  --editor-dropdown-border:rgba(16,23,34,.12);
  --editor-dropdown-shadow:0 16px 40px rgba(15,23,42,.14);

  --editor-toolbar-bg:rgba(255,255,255,.96);
  --editor-toolbar-bg-2:rgba(255,255,255,.88);
  --editor-toolbar-border:rgba(16,23,34,.10);
  --editor-toolbar-shadow:0 10px 26px rgba(15,23,42,.10);

  --editor-scrollbar-track:transparent;
  --editor-scrollbar-thumb:rgba(16,23,34,.16);
  --editor-scrollbar-thumb-hover:rgba(16,23,34,.28);

  --editor-shell-bg:var(--editor-surface);
  --editor-shell-sidebar-bg:rgba(16,23,34,.015);
  --editor-shell-main-bg:transparent;

  --editor-icon-bg:color-mix(in srgb, var(--editor-primary) 10%, transparent);
  --editor-icon-color:#4338ca;
  --editor-focus-ring:color-mix(in srgb, var(--editor-primary) 26%, transparent);

  --editor-shadow-xs:0 1px 2px rgba(15,23,42,.06);
  --editor-shadow-sm:0 4px 12px rgba(15,23,42,.08);
  --editor-shadow-md:0 10px 28px rgba(15,23,42,.12);
  --editor-shadow-lg:0 24px 60px rgba(15,23,42,.18);
  --editor-elevated-bg:#ffffff;
  --editor-elevated-border:rgba(16,23,34,.12);
  --editor-panel-glow:0 0 0 1px transparent;
  --editor-input-hover-bg:#f8fafd;
  --editor-disabled-opacity:.5;
}

.editor-theme{
  font-family:var(--editor-font);
  /* Спокойный фон: один мягкий градиент сверху вместо трёх цветных пятен —
     текст читается ровнее, а страница не «переливается» при прокрутке. */
  background:
    radial-gradient(1100px circle at 50% -20%, var(--editor-bg-gradient-1), transparent 62%),
    var(--editor-bg);
  background-repeat:no-repeat;
  min-height:100vh;
  min-height:100dvh;
  color:var(--editor-text);
  font-size:var(--editor-font-size);
  line-height:var(--editor-line-height);
  color-scheme:var(--editor-color-scheme);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
  isolation:isolate;
}

.editor-theme,
.editor-theme *{
  box-sizing:border-box;
}

.editor-theme ::selection{
  background:var(--editor-focus-ring);
  color:var(--editor-text);
}

.editor-theme :where(a){
  color:var(--editor-primary);
  text-decoration:none;
}

.editor-theme :where(a:hover){
  color:var(--editor-secondary);
}

.editor-surface{
  background:var(--editor-surface);
  border-color:var(--editor-border);
  color:var(--editor-text);
}

.editor-panel{
  background:var(--editor-surface);
  border-color:var(--editor-line);
  color:var(--editor-text);
}

/* Карточка — просто поверхность с волосяной рамкой. Ни подъёма при наведении,
   ни размытия: карточка не «прыгает» под курсором, а глаз не тратит силы
   на декоративные тени. */
.editor-card{
  background:var(--editor-surface);
  border:1px solid var(--editor-line);
  border-radius:var(--editor-radius-lg);
  color:var(--editor-text);
  box-shadow:none;
  transition:border-color .15s ease, background-color .15s ease;
}

.editor-card:hover{
  border-color:var(--editor-line-strong);
}

.editor-modal-backdrop{
  background:rgba(2,6,23,.68);
  backdrop-filter:blur(8px);
  display:flex;
  align-items:center;
  justify-content:center;
}

.editor-modal-content{
  background:var(--editor-surface);
  border:1px solid var(--editor-line-strong);
  border-radius:var(--editor-radius-lg);
  box-shadow:var(--editor-shadow-lg);
  color:var(--editor-text);
  /* Высокие формы не должны уходить за край экрана — прокручивается само окно. */
  max-height:calc(100vh - 2rem);
  max-height:calc(100dvh - 2rem);
  overflow:auto;
  overscroll-behavior:contain;
}

@media (max-width:640px){
  .editor-modal-content{
    border-radius:14px;
    max-height:calc(100vh - 1rem);
    max-height:calc(100dvh - 1rem);
  }
}

/* Окно с постоянной шапкой и подвалом: прокручивается только тело.
   Так заголовок и кнопки «Сохранить / Отмена» всегда на виду, а форма любой
   длины не растягивает окно за экран. */
.editor-modal-shell{
  display:flex;
  flex-direction:column;
  padding:0;
  overflow:hidden;
}

.editor-modal-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  flex:0 0 auto;
  padding:14px 20px;
  border-bottom:1px solid var(--editor-line);
}

.editor-modal-head-main{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.editor-modal-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  width:32px;
  height:32px;
  border-radius:var(--editor-radius-sm);
  font-size:14px;
  color:var(--editor-icon-color);
  background:var(--editor-icon-bg);
}

.editor-modal-title{
  margin:0;
  font-size:16px;
  font-weight:700;
  line-height:1.3;
  letter-spacing:-.01em;
  min-width:0;
  overflow-wrap:anywhere;
}

.editor-modal-body{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  padding:16px 20px;
}

.editor-modal-foot{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex:0 0 auto;
  padding:12px 20px;
  border-top:1px solid var(--editor-line);
  background:var(--editor-surface);
}

@media (max-width:640px){
  .editor-modal-head{padding:12px 14px;}
  .editor-modal-body{padding:12px 14px;}
  .editor-modal-foot{padding:10px 14px;}
  .editor-modal-foot .editor-btn{flex:1 1 auto;justify-content:center;}
}

.editor-toast-container{
  position:fixed;
  top:16px;
  right:16px;
  z-index:9999;
  display:flex;
  flex-direction:column;
  gap:8px;
  max-width:min(420px, calc(100vw - 32px));
}

/* Тост: спокойная поверхность и цветная полоса слева. Раньше это был яркий
   залитый прямоугольник — он перетягивал внимание с самой формы. */
.editor-toast-container .toast{
  --toast-accent:var(--editor-primary);
  background:var(--editor-surface-2) !important;
  color:var(--editor-text) !important;
  border:1px solid var(--editor-line-strong);
  border-left:3px solid var(--toast-accent);
  border-radius:var(--editor-radius-md);
  padding:10px 14px;
  font-size:var(--editor-text-md);
  font-weight:500;
  line-height:1.45;
  box-shadow:var(--editor-shadow-md);
  transform:translateX(0);
}

.editor-toast-container .toast{display:flex;align-items:flex-start;gap:12px;pointer-events:auto;}
.editor-toast-message{min-width:0;flex:1;overflow-wrap:anywhere;white-space:pre-line;}
.editor-toast-close{flex:0 0 28px;min-height:28px;border-radius:6px;font-size:20px;line-height:1;
  color:var(--editor-text-muted);background:transparent;border:0;cursor:pointer;}
.editor-toast-close:hover{background:var(--editor-soft-bg);color:var(--editor-text);}
.editor-toast-close:focus-visible{outline:2px solid var(--editor-primary);outline-offset:2px;}
.editor-toast-container .toast.bg-red-500{--toast-accent:var(--editor-danger);}
.editor-toast-container .toast.bg-yellow-500{--toast-accent:var(--editor-warning);}
.editor-toast-container .toast.bg-green-500{--toast-accent:var(--editor-success);}
.editor-toast-container .toast.bg-sky-600{--toast-accent:var(--editor-primary);}

@media (max-width:640px){
  .editor-toast-container{left:12px;right:12px;top:12px;max-width:none;}
}

/* Пустое состояние: иконка, заголовок, подсказка. Даже если в разметке только
   текст, он читается как спокойная плашка, а не как потерянная строка. */
.editor-empty-state{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:26px 18px;
  text-align:center;
  color:var(--editor-text-muted);
  font-size:var(--editor-text-md);
  line-height:1.5;
}

.editor-empty-state > i{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:38px;
  height:38px;
  margin-bottom:4px;
  border-radius:var(--editor-radius-md);
  background:var(--editor-soft-bg);
  border:1px solid var(--editor-line);
  font-size:15px;
  color:var(--editor-text-muted);
}

.editor-empty-state b,
.editor-empty-state strong{color:var(--editor-text);}

/* Подсказка под полем: мельче и тише подписи, но читаемая. */
.editor-help-text{
  margin-top:4px;
  font-size:var(--editor-text-sm);
  line-height:1.45;
  color:var(--editor-text-muted);
}

.text-accent{color:var(--editor-accent);}
.text-secondary{color:var(--editor-secondary);}
.text-primary{color:var(--editor-primary);}
.bg-light{background:var(--editor-light-bg);}
.border-light{border-color:var(--editor-light-border);}
.hover\:bg-light:hover{background:var(--editor-light-hover);}
.hover\:text-secondary:hover{color:var(--editor-secondary);}
.focus\:ring-primary:focus{box-shadow:0 0 0 3px var(--editor-focus-ring);}

.editor-theme input[type="text"],
.editor-theme input[type="number"],
.editor-theme input[type="search"],
.editor-theme input[type="date"],
.editor-theme input[type="time"],
.editor-theme input[type="datetime-local"],
.editor-theme input[type="email"],
.editor-theme input[type="url"],
.editor-theme input[type="password"],
.editor-theme textarea,
.editor-theme select{
  appearance:none;
  background:var(--editor-input-bg);
  border:1px solid var(--editor-border);
  color:var(--editor-text);
  border-radius:var(--editor-radius-md);
  box-shadow:none;
  transition:border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.editor-theme input::placeholder,
.editor-theme textarea::placeholder{
  color:var(--editor-text-muted);
  opacity:.85;
}

.editor-theme input:hover,
.editor-theme textarea:hover,
.editor-theme select:hover{
  border-color:var(--editor-soft-border-strong);
  background:var(--editor-input-hover-bg);
}

.editor-theme input:focus,
.editor-theme textarea:focus,
.editor-theme select:focus{
  outline:none;
  border-color:var(--editor-primary);
  background:var(--editor-input-bg);
  box-shadow:0 0 0 3px var(--editor-focus-ring);
}

/* Фокус с клавиатуры виден всегда — даже если у поля снят outline. */
.editor-theme :is(input, textarea, select):focus-visible{
  outline:2px solid var(--editor-primary);
  outline-offset:1px;
}

.editor-theme select,
.editor-theme input[type="date"],
.editor-theme input[type="time"],
.editor-theme input[type="datetime-local"]{
  color-scheme:var(--editor-color-scheme);
}

.editor-theme select option{
  background:var(--editor-surface);
  color:var(--editor-text);
}

.editor-theme :is(input, textarea, select):disabled,
.editor-theme :is(input, textarea, select)[aria-disabled="true"]{
  opacity:var(--editor-disabled-opacity);
  cursor:not-allowed;
  box-shadow:none;
}

.editor-input,
.editor-theme .form-input,
.editor-theme .form-select,
.editor-theme .form-textarea{
  width:100%;
  min-height:var(--editor-control-h);
  padding:0 12px;
  font-size:var(--editor-text-md);
  line-height:1.3;
  border-radius:var(--editor-radius-md);
  background:var(--editor-input-bg);
  border:1px solid var(--editor-border);
  color:var(--editor-text);
  box-shadow:none;
}

.editor-theme textarea.editor-input,
.editor-theme textarea.form-input,
.editor-theme .form-textarea{
  padding:9px 12px;
}

/* Стрелка у select: без неё поле выглядит как обычный input и его
   не отличить от текстового. */
.editor-theme select.editor-input,
.editor-theme select.form-input,
.editor-theme select.form-select{
  padding-right:34px;
  background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2397a3b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
}

:root[data-editor-theme="light"] .editor-theme select.editor-input,
:root[data-editor-theme="light"] .editor-theme select.form-input,
:root[data-editor-theme="light"] .editor-theme select.form-select{
  background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%235f6b7d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
}

.editor-theme .form-textarea,
.editor-textarea,
.editor-theme textarea{
  min-height:104px;
  resize:vertical;
}

.editor-textarea{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;
  font-size:.88rem;
}

/* Поле формы — это подпись + контрол + подсказка, без собственной рамки.
   Раньше каждое поле было отдельной «карточкой в карточке»: рамки, тени и
   подсветка складывались и форма превращалась в решётку из рамок. */
.editor-field,
.editor-list-item{
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  gap:6px;
  min-width:0;
  padding:0;
  border-radius:0;
  background:transparent;
  border:0;
  box-shadow:none;
  transition:border-color .14s ease, background-color .14s ease;
}

.editor-field{min-height:0;}

/* Элемент списка остаётся карточкой: он — отдельная сущность (моб, слот,
   запись), и его нужно отличать от соседних. */
.editor-list-item{
  min-height:0;
  height:auto;
  gap:8px;
  padding:12px;
  border-radius:var(--editor-radius-md);
  background:var(--editor-surface-2);
  border:1px solid var(--editor-line);
}

.editor-list-item:hover{
  border-color:var(--editor-line-strong);
}

.editor-field:focus-within .editor-label,
.editor-field:focus-within .editor-nested-label{
  color:var(--editor-primary);
}

.editor-field-nested{
  display:block;
  min-width:0;
  padding:0;
  border:0;
  background:transparent;
  box-shadow:none;
  backdrop-filter:none;
}

.editor-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-height:var(--editor-control-h);
  padding:0 14px;
  border-radius:var(--editor-radius-md);
  font-size:var(--editor-text-md);
  font-weight:600;
  letter-spacing:0;
  line-height:1;
  white-space:nowrap;
  border:1px solid var(--editor-button-secondary-border);
  background:var(--editor-button-secondary-bg);
  color:var(--editor-text);
  box-shadow:none;
  transition:background-color .14s ease, border-color .14s ease, color .14s ease;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
}

.editor-btn:hover{
  background:var(--editor-button-secondary-hover-bg);
  border-color:var(--editor-soft-border-strong);
}

.editor-btn:focus-visible,
.editor-icon-btn:focus-visible,
.editor-dbcombo-clear:focus-visible,
.editor-dbcombo-option:focus-visible,
.editor-tag-option:focus-visible,
.editor-tag:focus-visible,
.editor-details summary:focus-visible{
  outline:none;
  box-shadow:0 0 0 4px var(--editor-focus-ring);
}

.editor-btn:active,
.editor-icon-btn:active{
  filter:brightness(.96);
}

.editor-btn[disabled],
.editor-icon-btn[disabled],
.editor-dbcombo-clear[disabled]{
  opacity:.55;
  cursor:not-allowed;
  box-shadow:none;
}

.editor-btn-secondary{
  background:var(--editor-button-secondary-bg);
  color:var(--editor-text);
  border-color:var(--editor-button-secondary-border);
}

.editor-btn-secondary:hover{
  background:var(--editor-button-secondary-hover-bg);
  border-color:var(--editor-soft-border-strong);
}

.editor-btn.active{
  background:color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border-color:color-mix(in srgb, var(--editor-primary) 48%, transparent);
  color:var(--editor-text-strong);
}

/* Главная кнопка: сплошной акцент, белый текст, без градиента и «свечения».
   На экране одна-две такие кнопки — остальные вторичные. */
.editor-btn-primary{
  background:var(--editor-primary);
  color:#fff;
  border-color:transparent;
  box-shadow:none;
  /* Светлые акценты (amber, sky, emerald) иначе плохо читаются с белым текстом. */
  text-shadow:0 1px 2px rgba(0,0,0,.28);
}

.editor-btn-primary:hover{
  background:color-mix(in srgb, var(--editor-primary) 88%, #ffffff);
  border-color:transparent;
}

.editor-btn-danger{
  background:var(--editor-danger);
  color:#fff;
  border-color:transparent;
}

.editor-btn-danger:hover{
  background:color-mix(in srgb, var(--editor-danger) 88%, #ffffff);
}

/* Строка списка: плоская, плотная, с полосой-индикатором выбора.
   В списке из сотни записей важнее плотность и ровный ритм, чем «карточность». */
.editor-row{
  position:relative;
  display:block;
  padding:7px 10px 7px 12px;
  border-radius:var(--editor-radius-sm);
  border:1px solid transparent;
  background:transparent;
  cursor:pointer;
  transition:background .12s ease, border-color .12s ease;
  contain:layout style paint;
}

.editor-row:hover{
  background:var(--editor-row-hover-bg);
  border-color:transparent;
}

.editor-row .font-semibold{
  font-size:var(--editor-text-md);
  font-weight:600;
  line-height:1.35;
}

.editor-row .text-xs{
  margin-top:1px;
  font-size:var(--editor-text-xs);
  line-height:1.35;
}

.editor-row.editor-row-active{
  background:var(--editor-row-active-bg);
  border-color:transparent;
}

.editor-row.editor-row-active .font-semibold{
  color:var(--editor-text-strong);
}

/* Навигация по записям над списком (ui-manager): ↑/↓ и позиция «N / M». */
.editor-record-nav{
  display:flex;
  align-items:center;
  gap:6px;
  margin:0 0 8px;
}

.editor-record-nav-btn{
  min-width:30px;
  min-height:30px;
}

.editor-record-nav-pos{
  font-size:var(--editor-text-xs);
  color:var(--editor-text-muted);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

/* Клавиатурный фокус на строке должен быть виден: по списку ходят стрелками. */
.editor-row:focus-visible,
.quest-node:focus-visible,
.step-node:focus-visible,
.cr-list-item:focus-visible{
  outline:2px solid var(--editor-primary);
  outline-offset:1px;
}

.editor-db-alert{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--editor-border);
  background:var(--editor-soft-bg);
  color:var(--editor-text-muted);
}

.editor-icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-width:var(--editor-control-h);
  min-height:var(--editor-control-h);
  padding:0;
  border-radius:var(--editor-radius-md);
  border:1px solid var(--editor-icon-btn-border);
  background:var(--editor-icon-btn-bg);
  color:var(--editor-text-muted);
  box-shadow:none;
  transition:background .14s ease, border-color .14s ease, color .14s ease;
}

.editor-icon-btn:hover{
  background:var(--editor-icon-btn-hover-bg);
  border-color:var(--editor-soft-border-strong);
  color:var(--editor-text);
}

.editor-icon-danger{
  color:rgba(248,113,113,.98);
  border-color:rgba(248,113,113,.35);
  background:rgba(248,113,113,.08);
}

.editor-icon-danger:hover{
  background:rgba(248,113,113,.14);
  border-color:rgba(248,113,113,.45);
}

.editor-muted-text{color:var(--editor-text-muted);}

/* Семантические утилиты вместо Tailwind-палитры (slate/indigo): страницы
   не знают, тёмная тема сейчас или светлая, и не могут «провалиться» в
   нечитаемый серый. */
.editor-text{color:var(--editor-text);}
.editor-primary-text{color:var(--editor-primary);}
.editor-hairline{border-color:var(--editor-line);}
.editor-hairline-strong{border-color:var(--editor-line-strong);}
.editor-soft{background:var(--editor-soft-bg);}
.editor-soft-strong{background:var(--editor-soft-bg-strong);}
.editor-primary-border{border-color:var(--editor-primary);}
.editor-primary-tint{background:color-mix(in srgb, var(--editor-primary) 5%, transparent);}
.editor-hover:hover{background:var(--editor-row-hover-bg);}
.editor-hover-text:hover{color:var(--editor-text);}
.editor-hover-danger:hover{color:var(--editor-danger);}
.editor-hover-warning:hover{color:var(--editor-warning);}
.editor-hover-accent:hover{color:var(--editor-primary);}
.editor-hairline-l{border-left-color:var(--editor-line-strong);}

/* Подпись поля: 12.5px, полужирная, приглушённая. Значение в контроле ярче
   подписи — глаз сначала читает данные, потом название поля. */
.editor-label{
  display:block;
  font-size:var(--editor-text-sm);
  font-weight:600;
  line-height:1.35;
  color:var(--editor-text-muted);
  letter-spacing:0;
  transition:color .14s ease;
}
.editor-label-icon{
  width:var(--editor-icon-size);
  height:var(--editor-icon-size);
  border-radius:999px;
  background:var(--editor-icon-bg);
  color:var(--editor-icon-color);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  flex:0 0 var(--editor-icon-size);
}

.editor-nested-label{
  display:block;
  margin-bottom:4px;
  font-size:var(--editor-text-xs);
  color:var(--editor-text-muted);
  font-weight:600;
  letter-spacing:.01em;
  transition:color .14s ease;
}

.editor-validation-hint{color:rgba(248,113,113,.95);}
.editor-invalid{border-color:rgba(248,113,113,.8)!important;box-shadow:0 0 0 4px rgba(248,113,113,.14)!important;}

.editor-theme .text-slate-100{color:var(--editor-text);}
.editor-theme .text-slate-200,
.editor-theme .text-slate-300,
.editor-theme .text-slate-400,
.editor-theme .text-slate-500,
.editor-theme .text-slate-600{color:var(--editor-text-muted);}
.editor-theme .border-slate-200/30,
.editor-theme .border-slate-300/40,
.editor-theme .border-slate-700/40,
.editor-theme .border-slate-600/80,
.editor-theme .border-slate-800/80,
.editor-theme .border-slate-200,
.editor-theme .border-slate-300{border-color:var(--editor-light-border);}
.editor-theme .bg-white/5{background:var(--editor-soft-bg-strong);}
.editor-theme .bg-white/10{background:var(--editor-light-hover);}
.editor-theme .bg-black/10{background:var(--editor-soft-bg);}
.editor-theme .border-white/10{border-color:var(--editor-soft-border);}
.editor-theme[data-editor-theme="light"] .bg-slate-700/40,
.editor-theme[data-editor-theme="light"] .bg-slate-800/60,
.editor-theme[data-editor-theme="light"] .bg-slate-800/70,
.editor-theme[data-editor-theme="light"] .bg-slate-500/70{background:var(--editor-soft-bg);}
.editor-theme[data-editor-theme="light"] .hover\:bg-slate-700/40:hover{background:var(--editor-soft-bg-strong);}

.editor-toggle{
  display:inline-flex;
  align-items:center;
  gap:.55rem;
  user-select:none;
}

.editor-toggle input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.editor-toggle-track{
  width:40px;
  height:22px;
  border-radius:999px;
  background:var(--editor-soft-bg-strong);
  border:1px solid var(--editor-line-strong);
  position:relative;
  transition:background .15s ease,border-color .15s ease;
}

/* Флажок: системный чекбокс в цвете акцента. Раньше он был тёмным квадратом
   с синей заливкой и читался хуже, чем обычный. */
.editor-theme input[type="checkbox"],
.editor-theme input[type="radio"]{
  accent-color:var(--editor-primary);
  width:16px;
  height:16px;
  cursor:pointer;
}

.editor-toggle:has(input:checked) .editor-toggle-track,
.editor-toggle[data-checked="1"] .editor-toggle-track{
  background:var(--editor-primary);
  border-color:var(--editor-primary);
}

.editor-toggle-knob{
  width:16px;
  height:16px;
  border-radius:999px;
  background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.25);
  position:absolute;
  top:2px;
  left:2px;
  transition:transform .15s ease;
}

.editor-toggle[data-checked="1"] .editor-toggle-knob{
  transform:translateX(18px);
}

.editor-dbcombo{
  position:relative;
  display:flex;
  flex-direction:column;
  gap:.45rem;
  min-width:0;
}

.editor-dbcombo-control{
  position:relative;
  min-width:0;
}

.editor-dbcombo-input{padding-right:2.35rem;}
.editor-dbcombo-input::-webkit-search-cancel-button{display:none;-webkit-appearance:none;}

.editor-dbcombo-clear{
  position:absolute;
  right:.45rem;
  top:50%;
  transform:translateY(-50%);
  width:1.6rem;
  height:1.6rem;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--editor-button-secondary-bg);
  border:1px solid var(--editor-button-secondary-border);
  color:var(--editor-text-muted);
  cursor:pointer;
  transition:background-color .14s ease, border-color .14s ease, color .14s ease;
}

.editor-dbcombo-clear[hidden]{
  display:none;
}

.editor-dbcombo-clear:hover{
  background:color-mix(in srgb, var(--editor-danger) 14%, var(--editor-button-secondary-hover-bg));
  border-color:color-mix(in srgb, var(--editor-danger) 40%, var(--editor-soft-border-strong));
  color:var(--editor-danger);
}

.editor-required-mark{
  color:var(--editor-danger);
  font-weight:700;
  margin-left:3px;
  line-height:1;
}

.editor-dbcombo-dropdown{
  display:none;
  position:absolute;
  left:0;
  right:0;
  top:calc(var(--editor-control-h) + .6rem);
  z-index:500;
  max-height:280px;
  overflow:auto;
  border-radius:14px;
  background:var(--editor-dropdown-bg);
  border:1px solid var(--editor-dropdown-border);
  box-shadow:var(--editor-dropdown-shadow);
  backdrop-filter:blur(14px);
  padding:.35rem;
}

.editor-dbcombo-dropdown-portal{
  position:fixed;
  left:0;
  top:0;
  right:auto;
  bottom:auto;
  z-index:10000;
}

.editor-dbcombo-dropdown.open{display:block;}

.editor-dbcombo-empty{
  padding:.7rem .8rem;
  font-size:.9rem;
  opacity:.75;
}

.editor-dbcombo-option{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  text-align:left;
  width:100%;
  padding:.5rem .6rem;
  border-radius:var(--editor-radius-sm);
  background:transparent;
  border:1px solid transparent;
  color:var(--editor-text);
  transition:background .15s ease,border-color .15s ease,transform .12s ease;
}

.editor-dbcombo-option:hover{
  background:var(--editor-soft-bg-strong);
  border-color:var(--editor-soft-border);
}

.editor-dbcombo-option.active{
  background:color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border-color:color-mix(in srgb, var(--editor-primary) 34%, transparent);
}

.editor-dbcombo-option-label{
  flex:1;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.editor-dbcombo-option--request{
  border-color:color-mix(in srgb, var(--editor-primary) 38%, transparent);
  background:color-mix(in srgb, var(--editor-primary) 10%, transparent);
  box-shadow:inset 3px 0 0 color-mix(in srgb, var(--editor-primary) 78%, transparent);
}
.editor-dbcombo-option--request:hover,
.editor-dbcombo-option--request.active{
  border-color:color-mix(in srgb, var(--editor-primary) 52%, transparent);
  background:color-mix(in srgb, var(--editor-primary) 17%, transparent);
}

.editor-dbcombo-option--draft{
  border-color:color-mix(in srgb, var(--editor-warning) 38%, transparent);
  background:color-mix(in srgb, var(--editor-warning) 9%, transparent);
  box-shadow:inset 3px 0 0 color-mix(in srgb, var(--editor-warning) 80%, transparent);
}
.editor-dbcombo-option--draft:hover,
.editor-dbcombo-option--draft.active{
  border-color:color-mix(in srgb, var(--editor-warning) 52%, transparent);
  background:color-mix(in srgb, var(--editor-warning) 16%, transparent);
}

.editor-dbcombo-option-badge{
  flex:0 0 auto;
  padding:2px 7px;
  border:1px solid transparent;
  border-radius:999px;
  font-size:10px;
  font-weight:700;
  line-height:1.35;
  white-space:nowrap;
}
.editor-dbcombo-option-badge--request{
  color:var(--editor-primary);
  border-color:color-mix(in srgb, var(--editor-primary) 36%, transparent);
  background:color-mix(in srgb, var(--editor-primary) 13%, transparent);
}
.editor-dbcombo-option-badge--draft{
  color:var(--editor-warning);
  border-color:color-mix(in srgb, var(--editor-warning) 36%, transparent);
  background:color-mix(in srgb, var(--editor-warning) 13%, transparent);
}

.editor-dbcombo-bound{display:none;}
.editor-dbcombo[data-db-state="connected"] .editor-dbcombo-bound{display:none;}
.editor-dbcombo[data-db-state="disconnected"] .editor-dbcombo-control{display:none;}
.editor-dbcombo[data-db-state="disconnected"] .editor-dbcombo-dropdown{display:none;}
.editor-dbcombo[data-db-state="disconnected"] .editor-dbcombo-bound{display:block;}

.editor-tags{
  display:flex;
  flex-direction:column;
  gap:.65rem;
  min-width:0;
}

.editor-tags-selected{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
  max-height:7.75rem;
  overflow:auto;
  padding-right:.15rem;
}

.editor-tags-empty{font-size:.85rem;opacity:.75;}

.editor-tag{
  display:inline-flex;
  align-items:center;
  gap:.45rem;
  max-width:100%;
  padding:.4rem .62rem;
  border-radius:999px;
  background:var(--editor-tag-bg);
  border:1px solid var(--editor-tag-border);
  color:var(--editor-text);
  transition:background .15s ease,border-color .15s ease,transform .12s ease;
}

.editor-tag-label{
  max-width:22rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.editor-tag:hover{
  background:var(--editor-tag-hover-bg);
  border-color:var(--editor-tag-hover-border);
}

.editor-tag-x{opacity:.85;font-weight:700;}
.editor-tags-searchrow{display:flex;}

.editor-tags-options{
  max-height:220px;
  overflow:auto;
  border-radius:14px;
  background:var(--editor-soft-bg);
  border:1px solid var(--editor-soft-border);
  box-shadow:var(--editor-panel-glow);
}

.editor-tags-options-inner{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
  gap:.4rem;
  padding:.45rem;
}

.editor-tag-option{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  text-align:left;
  width:100%;
  padding:.52rem .66rem;
  border-radius:12px;
  background:transparent;
  border:1px solid transparent;
  color:var(--editor-text);
  transition:background .15s ease,border-color .15s ease,transform .12s ease;
}

.editor-tag-option:hover{
  background:var(--editor-soft-bg-strong);
  border-color:var(--editor-soft-border);
}

.editor-tag-option.active{
  background:color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border-color:color-mix(in srgb, var(--editor-primary) 34%, transparent);
}

.editor-tag-option-strong{font-weight:700;}

.editor-field,
.editor-field-nested,
.editor-dbcombo,
.editor-dbcombo-control,
.editor-theme .grid > *{
  min-width:0;
}

.editor-grid-fields{
  display:grid;
  gap:var(--editor-grid-gap,.75rem);
  grid-template-columns:var(--editor-grid-template,1fr);
  min-width:0;
}

@media (min-width:768px){
  .editor-grid-fields{
    grid-template-columns:var(--editor-grid-template-md,repeat(2,minmax(0,1fr)));
  }
}

@media (min-width:1024px){
  .editor-grid-fields{
    grid-template-columns:var(--editor-grid-template-lg,var(--editor-grid-template-md,repeat(2,minmax(0,1fr))));
  }
}

/* Секция формы: подложка на полтона, без тени — она не «висит» над
   страницей, а просто группирует поля. */
.editor-section{
  background:var(--editor-soft-bg);
  border:1px solid var(--editor-line);
  border-radius:var(--editor-radius-md);
  padding:var(--editor-gap-4);
}

.editor-section + .editor-section{margin-top:var(--editor-gap-3);}

.editor-theme{
  scrollbar-width:thin;
  scrollbar-color:var(--editor-scrollbar-thumb) transparent;
}

.editor-theme *{
  scrollbar-width:thin;
  scrollbar-color:var(--editor-scrollbar-thumb) transparent;
}

.editor-theme ::-webkit-scrollbar{
  width:10px;
  height:10px;
}

.editor-theme ::-webkit-scrollbar-track{
  background:var(--editor-scrollbar-track);
  border-radius:999px;
}

.editor-theme ::-webkit-scrollbar-thumb{
  background:var(--editor-scrollbar-thumb);
  border-radius:999px;
  border:2px solid rgba(0,0,0,0);
  background-clip:padding-box;
}

.editor-theme ::-webkit-scrollbar-thumb:hover{
  background:var(--editor-scrollbar-thumb-hover);
}

.editor-scroll{overflow:auto;}

.editor-badge{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:3px 9px;
  border-radius:999px;
  font-size:var(--editor-text-xs);
  font-weight:600;
  line-height:1.5;
  border:1px solid var(--editor-badge-border);
  background:var(--editor-badge-bg);
  color:var(--editor-text-muted);
}

/* Только для чтения: та же высота, что у поля, но без намёка на ввод. */
.editor-readonly{
  min-height:var(--editor-control-h);
  padding:.5rem .75rem;
  border-radius:var(--editor-radius-sm);
  border:1px solid var(--editor-line);
  background:var(--editor-soft-bg);
  display:flex;
  align-items:center;
  color:var(--editor-text);
}

/* Панель над формой: имя записи слева, действия справа. Липнет к верху при
   прокрутке длинной формы — кнопки «Сохранить» всегда под рукой. */
.editor-sticky-toolbar{
  position:sticky;
  top:8px;
  z-index:30;
  background:var(--editor-toolbar-bg);
  border:1px solid var(--editor-line);
  border-radius:var(--editor-radius-lg);
  padding:12px 14px;
  box-shadow:var(--editor-toolbar-shadow);
}

.editor-search{position:relative;}
.editor-search i{
  position:absolute;
  left:12px;
  top:50%;
  transform:translateY(-50%);
  opacity:.78;
}
.editor-search input{padding-left:2.35rem;}

.editor-details{
  border:1px solid var(--editor-soft-border);
  border-radius:14px;
  background:var(--editor-soft-bg);
}

.editor-details summary{
  cursor:pointer;
  list-style:none;
  padding:10px 12px;
  font-size:12px;
  color:var(--editor-text-muted);
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.editor-details summary::-webkit-details-marker{display:none;}

.editor-details[open] summary{
  color:var(--editor-text);
  border-bottom:1px solid var(--editor-soft-border);
}

.editor-details .editor-details-body{
  padding:0 12px 12px;
}


@media (max-width:640px){
  .editor-tags-selected{max-height:9.5rem;}
  .editor-tag-label{max-width:14rem;}
  .editor-tags-options{max-height:180px;}
  .editor-tags-options-inner{grid-template-columns:repeat(auto-fill,minmax(140px,1fr));}
  .editor-toast-container{left:1rem;right:1rem;top:1rem;}
}

.editor-scenario-toolbar{
  display:flex;
  gap:.5rem;
  align-items:center;
  flex-wrap:wrap;
}

.editor-scenario-overlay-panel{
  width:100vw;
  max-width:100vw;
  height:100vh;
  height:100dvh;
  max-height:100vh;
  max-height:100dvh;
  display:flex;
  flex-direction:column;
  padding:0;
  overflow:hidden;
  border-radius:0;
}

.editor-scenario-overlay-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  padding:12px 14px;
  border-bottom:1px solid var(--editor-border);
  background:var(--editor-soft-bg);
}

.editor-scenario-overlay-title{
  font-size:1rem;
  font-weight:700;
}

.editor-scenario-overlay-controls{
  display:flex;
  align-items:center;
  gap:.55rem;
}

.editor-scenario-overlay-controls select{
  min-height:38px;
}

.editor-scenario-overlay-body{
  flex:1;
  min-height:0;
}

.editor-scenario-overlay-frame{
  display:block;
  width:100%;
  height:100%;
  border:0;
  background:var(--editor-bg);
}

@media (prefers-reduced-motion:reduce){
  .editor-card,
  .editor-row,
  .editor-btn,
  .editor-field,
  .editor-icon-btn,
  .editor-dbcombo-option,
  .editor-tag,
  .editor-tag-option{
    transition:none !important;
  }
}

/* Unified operation status -------------------------------------------------- */
.editor-status{
  display:flex;
  align-items:flex-start;
  gap:.55rem;
  min-height:1.25rem;
  font-size:.86rem;
  line-height:1.45;
  color:var(--editor-text-muted);
}
.editor-status:not(:empty){
  width:fit-content;
  max-width:100%;
  padding:.55rem .72rem;
  border:1px solid var(--editor-soft-border);
  border-radius:11px;
  background:var(--editor-soft-bg);
}
.editor-status:not(:empty)::before{
  content:"\f05a";
  margin-top:.12rem;
  font-family:"Font Awesome 6 Free";
  font-weight:900;
  flex:0 0 auto;
}
.editor-status--success{color:var(--editor-success);}
.editor-status--success:not(:empty){border-color:color-mix(in srgb,var(--editor-success) 35%,transparent);background:color-mix(in srgb,var(--editor-success) 9%,transparent);}
.editor-status--success:not(:empty)::before{content:"\f058";}
.editor-status--error{color:var(--editor-danger);}
.editor-status--error:not(:empty){border-color:color-mix(in srgb,var(--editor-danger) 35%,transparent);background:color-mix(in srgb,var(--editor-danger) 9%,transparent);}
.editor-status--error:not(:empty)::before{content:"\f06a";}
.editor-status--warning{color:var(--editor-warning);}
.editor-status--warning:not(:empty){border-color:color-mix(in srgb,var(--editor-warning) 35%,transparent);background:color-mix(in srgb,var(--editor-warning) 9%,transparent);}
.editor-status--warning:not(:empty)::before{content:"\f071";}
.editor-status--small{font-size:.76rem;}

/* Плитка иконки в заголовке вкладки описана в editor-template.css (.editor-page-title > i):
   здесь только гасим декоративный ::before, если иконка задана разметкой. */
.editor-page-title:has(> i)::before{display:none;}
/* В сайдбаре список идёт почти без просветов — можно окинуть взглядом 10–12
   записей, а не три. */
.editor-sidebar-list .editor-list{gap:1px;}
.editor-sidebar-list .editor-row{border-radius:var(--editor-radius-sm);}
.editor-sidebar-list .editor-row-active::before{
  content:"";
  position:absolute;
  left:2px;
  top:7px;
  bottom:7px;
  width:2px;
  border-radius:999px;
  background:var(--editor-primary);
}
.editor-sidebar-list[aria-busy="true"]{opacity:.68;cursor:progress;}
.editor-sidebar-list[aria-busy="true"] *{pointer-events:none;}
.editor-sticky-toolbar::after{
  content:"";
  position:absolute;
  inset:auto 0 -1px;
  height:1px;
  background:var(--editor-line);
}

@media (max-width:640px){
  .editor-sticky-toolbar{top:6px;padding:10px;}
  .editor-sticky-toolbar > .editor-page-actions{width:100%;}
  .editor-sticky-toolbar > .editor-page-actions .editor-btn{min-width:0;}
  .editor-status:not(:empty){width:100%;}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sync Button & Badge
   ═══════════════════════════════════════════════════════════════════════════ */

/* Кнопка синхронизации — акцентная, но без «свечения». */
.editor-btn-sync {
  position: relative;
  background: color-mix(in srgb, var(--editor-accent) 8%, transparent) !important;
  border-color: color-mix(in srgb, var(--editor-accent) 28%, transparent) !important;
  color: var(--editor-accent) !important;
  transition: background-color .14s ease, border-color .14s ease;
}

.editor-btn-sync:hover {
  background: color-mix(in srgb, var(--editor-accent) 16%, transparent) !important;
  border-color: color-mix(in srgb, var(--editor-accent) 45%, transparent) !important;
}

.sync-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--editor-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(255, 124, 135, .5);
  line-height: 1;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sync Modal Panel
   ═══════════════════════════════════════════════════════════════════════════ */

.editor-sync-panel {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--editor-surface);
  border: 1px solid var(--editor-border);
  border-radius: var(--editor-radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
  overflow: hidden;
  margin: auto;
}

/* Ensure modal backdrop centers the panel */
#editor-sync-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-sync-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--editor-border);
}

.editor-sync-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-sync-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--editor-border);
  background: var(--editor-panel);
}

/* Target card */
.editor-sync-target-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(52, 211, 153, .06);
  border: 1px solid rgba(52, 211, 153, .2);
}

.editor-sync-target-empty {
  background: rgba(148, 163, 184, .05);
  border-color: rgba(148, 163, 184, .15);
}

.editor-sync-status-ok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #34d399;
}

.editor-sync-status-err {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #f87171;
}

/* Schema comparison result */
.editor-sync-schema-ok,
.editor-sync-schema-err {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
}

.editor-sync-schema-ok {
  background: rgba(52, 211, 153, .07);
  border: 1px solid rgba(52, 211, 153, .22);
}

.editor-sync-schema-err {
  background: rgba(248, 113, 113, .07);
  border: 1px solid rgba(248, 113, 113, .22);
}

.editor-sync-schema-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--editor-text-muted);
  font-size: 14px;
}

.editor-sync-schema-warnings,
.editor-sync-schema-issues {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.editor-sync-schema-warning,
.editor-sync-schema-issue {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.editor-sync-schema-warning {
  background: rgba(251, 191, 36, .06);
  border: 1px solid rgba(251, 191, 36, .15);
  color: #fbbf24;
}

.editor-sync-schema-issue {
  background: rgba(248, 113, 113, .06);
  border: 1px solid rgba(248, 113, 113, .15);
  color: #fca5a5;
}

/* Operations list */
.editor-sync-ops-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  text-align: center;
}

.editor-sync-ops-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.editor-sync-ops-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-sync-ops-group {
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  overflow: hidden;
}

.editor-sync-ops-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--editor-light-bg);
  border-bottom: 1px solid var(--editor-border);
}

.editor-sync-op-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, .04);
}

.editor-sync-op-row:last-child {
  border-bottom: none;
}

.editor-sync-op-icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-size: 11px;
}

.editor-sync-op-label {
  font-weight: 500;
  color: var(--editor-text);
}

.editor-sync-op-id {
  font-family: monospace;
  font-size: 12px;
  color: var(--editor-text-muted);
  background: var(--editor-soft-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.editor-sync-op-name {
  font-size: 12px;
  color: var(--editor-text);
  font-weight: 500;
  background: var(--editor-soft-bg);
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid var(--editor-soft-border);
}

.editor-sync-op-desc {
  font-size: 11px;
  color: var(--editor-text-muted);
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-sync-op-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--editor-text-muted);
}

.editor-sync-op-remove {
  flex-shrink: 0;
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
  font-size: 10px !important;
}

/* Confirm input */
.editor-sync-confirm {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--editor-light-bg);
  border: 1px solid var(--editor-border);
}

.editor-sync-confirm .editor-label {
  margin-bottom: 8px;
}

.editor-sync-profile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.editor-sync-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--editor-border);
  background: var(--editor-soft-bg);
  transition: border-color .15s;
}

.editor-sync-profile-card.is-target {
  border-color: color-mix(in srgb, var(--editor-accent) 35%, transparent);
  background: color-mix(in srgb, var(--editor-accent) 6%, transparent);
}

.editor-sync-profile-card:hover {
  border-color: var(--editor-soft-border-strong);
}

.editor-sync-profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.editor-sync-profile-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--editor-text);
}

.editor-sync-profile-details {
  font-size: 12px;
  color: var(--editor-text-muted);
}

.editor-sync-profile-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}


/* ── Reverse sync (target → current DB) ───────────────────────────────── */
.editor-sync-reverse {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 124, 135, .35);
  background: rgba(255, 124, 135, .04);
}

.editor-sync-reverse-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.editor-sync-reverse-head > i {
  color: var(--editor-danger);
  margin-top: 3px;
}

.editor-sync-reverse-actions {
  display: flex;
  gap: 8px;
}

.editor-sync-pull-apply {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-sync-pull-apply .editor-sync-confirm {
  flex: 1;
  min-width: 220px;
}

.editor-sync-warn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--editor-warning);
  background: rgba(255, 194, 127, .08);
  border: 1px solid rgba(255, 194, 127, .3);
}

.editor-sync-pull-summary {
  font-size: 13px;
}

.editor-sync-pull-details {
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--editor-soft-bg);
}

.editor-sync-pull-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--editor-text);
}

.editor-sync-pull-table-wrap,
.editor-sync-map-wrap {
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--editor-border);
  border-radius: 10px;
}

.editor-sync-map {
  min-height: 60px;
}

.editor-sync-map-wrap {
  max-height: 460px;
}

.editor-sync-pull-table,
.editor-sync-map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.editor-sync-pull-table th,
.editor-sync-map-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--editor-text);
  background: var(--editor-panel);
  border-bottom: 1px solid var(--editor-border);
}

.editor-sync-pull-table td,
.editor-sync-map-table td {
  padding: 6px 10px;
  color: var(--editor-text);
  border-bottom: 1px solid var(--editor-border);
  vertical-align: middle;
}

.editor-sync-map-table tr:last-child td,
.editor-sync-pull-table tr:last-child td {
  border-bottom: none;
}

/* Строка «не синхронизируется» в карте синхронизации: класс ставит settings.html. */
.editor-sync-map-table tr.dir-none td {
  opacity: .6;
}

.sync-dir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid var(--editor-border);
  color: var(--editor-text-muted);
}

.sync-dir-both {
  color: var(--editor-accent);
  background: color-mix(in srgb, var(--editor-accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--editor-accent) 35%, transparent);
}

.sync-dir-pull {
  color: #93c5fd;
  background: rgba(96, 165, 250, .12);
  border-color: rgba(96, 165, 250, .35);
}

.sync-dir-push {
  color: #c4b5fd;
  background: rgba(167, 139, 250, .12);
  border-color: rgba(167, 139, 250, .35);
}

/* ── Окно карты ─────────────────────────────────────────────────────────────
   Карта занимает почти весь экран: её двигают мышью, точку ставят кликом.
   Затемнение не блокирует прокрутку страницы (это ломало окно входа). */
.editor-map-dialog{
  position:fixed;
  inset:0;
  width:auto;
  height:auto;
  max-width:none;
  max-height:none;
  margin:0;
  border:0;
  color:inherit;
  z-index:620;
  display:none;
  align-items:center;
  justify-content:center;
  padding:var(--editor-gap-4);
  background:rgba(3,7,15,.72);
  backdrop-filter:blur(6px);
}

.editor-map-dialog.is-open{display:flex;}
.editor-map-dialog::backdrop{background:transparent;}

.editor-map-dialog-frame{
  position:relative;
  display:flex;
  flex-direction:column;
  width:100%;
  height:100%;
  max-width:1600px;
  overflow:hidden;
  border:1px solid var(--editor-line-strong);
  border-radius:var(--editor-radius-lg);
  box-shadow:var(--editor-shadow-lg);
  background:var(--editor-surface);
}

/* Мир для карты: нужен там, где у записи нет поля мира (компоненты сценария). */
.editor-map-dialog-world{
  display:flex;
  align-items:center;
  gap:10px;
  flex:0 0 auto;
  padding:8px 12px;
  border-bottom:1px solid var(--editor-line);
  background:var(--editor-surface);
}

.editor-map-dialog-world[hidden]{display:none;}

.editor-map-dialog-world-label{
  font-size:12px;
  font-weight:600;
  color:var(--editor-text-muted);
  white-space:nowrap;
}

.editor-map-dialog-world-select{
  flex:0 1 320px;
  min-width:0;
  height:34px;
  padding:0 10px;
  font-size:13px;
  color:var(--editor-text);
  background:var(--editor-surface-2);
  border:1px solid var(--editor-line-strong);
  border-radius:var(--editor-radius-sm);
}

.editor-map-dialog-world-select:focus-visible{
  outline:2px solid var(--editor-primary);
  outline-offset:1px;
}

.editor-map-dialog-frame-inner{
  display:block;
  flex:1 1 auto;
  width:100%;
  min-height:0;
  border:0;
}

html.editor-map-open{overflow:hidden;}

/* Телефон: карта занимает весь экран, а строка выбора мира не должна
   съедать половину высоты. Раньше здесь оставался padding диалога и рамка
   толщиной в экран — на 360px карта получала ~300px и подсказки панели
   ложились друг на друга. */
@media (max-width:640px){
  .editor-map-dialog{padding:0;}
  .editor-map-dialog-frame{
    width:100%;
    height:100%;
    max-width:none;
    max-height:100%;
    border:0;
    border-radius:0;
  }
  .editor-map-dialog-world{
    flex-wrap:wrap;
    gap:6px;
    padding:6px 10px;
  }
  .editor-map-dialog-world-label{font-size:11px;}
  .editor-map-dialog-world-select{
    flex:1 1 100%;
    height:36px;
    font-size:16px; /* iOS не зумит поле при фокусе */
  }
}

/* Modal layout must never override the visibility state, even when a modal
   has an ID selector (e.g. #editor-sync-modal) or styles load in a different order. */
.editor-modal-backdrop.hidden,
#editor-sync-modal.hidden {
  display: none !important;
}

/* =============================================================
   Акцентные пресеты (data-editor-accent) и плотность интерфейса
   (data-editor-density). Атрибуты ставит editor-core/tailwind-theme.js
   на <html> и <body class="editor-theme">; indigo/comfortable — значения
   по умолчанию из блоков выше.

   Пресет задаёт только цвет для тёмной и светлой темы. Производные токены
   (теги, активная строка, градиент, фокус, иконки) считаются от
   --editor-primary в базовых блоках, поэтому новый акцент не требует
   копирования всего набора правил. Список — editor-core/tailwind-theme.js.
   ============================================================= */

:root[data-editor-accent="indigo"],  .editor-theme[data-editor-accent="indigo"]  { --studio-accent-dark:#818cf8; --studio-accent-light:#4f46e5; }
:root[data-editor-accent="violet"],  .editor-theme[data-editor-accent="violet"]  { --studio-accent-dark:#a78bfa; --studio-accent-light:#7c3aed; }
:root[data-editor-accent="fuchsia"], .editor-theme[data-editor-accent="fuchsia"] { --studio-accent-dark:#e879f9; --studio-accent-light:#a21caf; }
:root[data-editor-accent="rose"],    .editor-theme[data-editor-accent="rose"]    { --studio-accent-dark:#fb7185; --studio-accent-light:#be123c; }
:root[data-editor-accent="orange"],  .editor-theme[data-editor-accent="orange"]  { --studio-accent-dark:#fb923c; --studio-accent-light:#c2410c; }
:root[data-editor-accent="amber"],   .editor-theme[data-editor-accent="amber"]   { --studio-accent-dark:#fbbf24; --studio-accent-light:#d97706; }
:root[data-editor-accent="emerald"], .editor-theme[data-editor-accent="emerald"] { --studio-accent-dark:#34d399; --studio-accent-light:#047857; }
:root[data-editor-accent="teal"],    .editor-theme[data-editor-accent="teal"]    { --studio-accent-dark:#2dd4bf; --studio-accent-light:#0d9488; }
:root[data-editor-accent="sky"],     .editor-theme[data-editor-accent="sky"]     { --studio-accent-dark:#38bdf8; --studio-accent-light:#0369a1; }
:root[data-editor-accent="slate"],   .editor-theme[data-editor-accent="slate"]   { --studio-accent-dark:#94a3b8; --studio-accent-light:#475569; }

:root[data-editor-theme="dark"][data-editor-accent]:not([data-editor-accent="indigo"]),
.editor-theme[data-editor-theme="dark"][data-editor-accent]:not([data-editor-accent="indigo"]){
  --editor-primary:var(--studio-accent-dark, #818cf8);
  --editor-secondary:color-mix(in srgb, var(--editor-primary) 68%, #ffffff);
  --editor-icon-color:color-mix(in srgb, var(--editor-primary) 45%, #ffffff);
}
:root[data-editor-theme="light"][data-editor-accent]:not([data-editor-accent="indigo"]),
.editor-theme[data-editor-theme="light"][data-editor-accent]:not([data-editor-accent="indigo"]){
  --editor-primary:var(--studio-accent-light, #4f46e5);
  --editor-secondary:color-mix(in srgb, var(--editor-primary) 78%, #000000);
  --editor-icon-color:color-mix(in srgb, var(--editor-primary) 80%, #000000);
}

/* Компактная плотность: ниже контролы, теснее отступы — для больших таблиц. */
:root[data-editor-density="compact"],
.editor-theme[data-editor-density="compact"]{
  --editor-control-h:32px;
  --editor-space:10px;
  --editor-space-sm:8px;
  --editor-font-size:13px;
  --editor-text-md:13px;
  --editor-text-lg:14px;
  --editor-gap-3:10px;
  --editor-gap-4:12px;
  --editor-gap-5:18px;
  --editor-gap-6:24px;
}

/* Видимый фокус с клавиатуры везде, где компонент не нарисовал свой. */
.editor-theme :where(button, a, input, select, textarea, [tabindex]):focus-visible{
  outline:2px solid var(--editor-primary);
  outline-offset:2px;
}

/* Уважаем системную настройку «меньше движения». */
@media (prefers-reduced-motion: reduce){
  .editor-theme *,
  .editor-theme *::before,
  .editor-theme *::after{
    animation-duration:.01ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.01ms !important;
    scroll-behavior:auto !important;
  }
}
