/* Оболочка Editor Studio (index.html): рельс меню, рабочая область,
   вкладки редакторов, палитра команд и окно входа.
   Всё оформление — на токенах editor-theme.css. */

/* Оболочка студии: боковое меню + рабочая область.
       Всё оформление — на токенах editor-theme.css, чтобы оболочка и сами
       редакторы выглядели как одно приложение. */
    html, body { height: 100%; }
    body { overflow: hidden; }
    .studio-iframe { width: 100%; height: 100%; border: 0; background: var(--editor-bg); }
    .studio-app { height: 100vh; height: 100dvh; }

    /* ── боковая панель: «рельс» из иконок ─────────────────────────────
       По умолчанию меню занимает минимум места: виден только столбец иконок
       (рельс). Наведение курсора или фокус с клавиатуры раскрывает панель
       ПОВЕРХ рабочей области — редактор в iframe при этом не пересобирается
       и не «прыгает». Когда область не активна, панель снова сворачивается
       до рельса. Кнопка в шапке (Ctrl+B) закрепляет панель открытой: тогда
       она занимает место в раскладке и ничего не перекрывает. */
    .studio-app {
      --studio-rail-w: 64px;
      --studio-panel-w: 292px;
    }
    @media (max-width: 1280px) { .studio-app { --studio-panel-w: 276px; } }
    @media (max-width: 1024px) { .studio-app { --studio-rail-w: 58px; --studio-panel-w: 260px; } }
    @media (max-width: 860px)  { .studio-app { --studio-rail-w: 52px; --studio-panel-w: 244px; } }
    @media (min-width: 1680px) { .studio-app { --studio-panel-w: 312px; } }

    .studio-sidebar {
      position: relative;
      flex: 0 0 auto;
      display: none;
      width: var(--studio-rail-w);
      z-index: 60;
      transition: width .2s ease;
    }
    @media (min-width: 768px) { .studio-sidebar { display: block; } }
    body.studio-sidebar-pinned .studio-sidebar { width: var(--studio-panel-w); }

    /* Панель вынесена из потока: раскрытие не меняет ширину рабочей области. */
    .studio-sidebar__panel {
      position: absolute; top: 0; bottom: 0; left: 0;
      display: flex; flex-direction: column;
      width: var(--studio-rail-w);
      overflow: hidden;
      background: var(--editor-surface);
      border-right: 1px solid var(--editor-line);
      transition: width .2s ease, box-shadow .2s ease;
    }
    .studio-sidebar.is-open .studio-sidebar__panel,
    body.studio-sidebar-pinned .studio-sidebar__panel {
      width: var(--studio-panel-w);
    }
    .studio-sidebar.is-open .studio-sidebar__panel {
      box-shadow: var(--editor-shadow-md);
    }

    /* ── рельс: видны только иконки ─────────────────────────────────── */
    .studio-sidebar.is-rail .studio-label,
    .studio-sidebar.is-rail .studio-item-text,
    .studio-sidebar.is-rail .studio-brand-text,
    .studio-sidebar.is-rail .studio-group-count { display: none; }

    .studio-sidebar.is-rail .studio-brand { padding: 14px 0; justify-content: center; }
    .studio-sidebar.is-rail .studio-nav { padding: 0 6px 10px; }
    .studio-sidebar.is-rail .studio-item { justify-content: center; gap: 0; padding: 6px 0; }
    .studio-sidebar.is-rail .studio-group-title {
      justify-content: center; padding: 10px 0 2px; margin-top: 4px;
    }
    /* Заголовок группы остаётся для скринридеров, но не занимает места. */
    .studio-sidebar.is-rail .studio-group-label {
      position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
      overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
      white-space: nowrap; border: 0;
    }
    .studio-sidebar.is-rail .studio-group-title::after {
      content: ''; width: 22px; height: 1px; background: var(--editor-line-strong);
    }
    /* Счётчик запросов в рельсе — точка в углу иконки. */
    .studio-sidebar.is-rail .studio-nav-badge {
      position: absolute; top: 4px; right: 10px;
      width: 8px; height: 8px; min-width: 0; padding: 0; border-radius: 999px;
      font-size: 0; line-height: 0; overflow: hidden;
      box-shadow: 0 0 0 2px var(--editor-surface);
    }
    .studio-sidebar.is-rail .studio-sidebar-foot {
      flex-direction: column; align-items: center; gap: 6px; padding: 10px 0;
    }
    .studio-sidebar.is-rail .studio-foot-btn {
      flex: 0 0 auto; width: 36px; min-width: 36px; height: 36px; padding: 0;
      justify-content: center;
    }

    /* ── мобильное меню (наведения на телефоне нет) ─────────────────── */
    .studio-drawer {
      width: min(320px, 86vw);
      background: var(--editor-surface);
      border-right: 1px solid var(--editor-line);
      display: flex; flex-direction: column;
    }

    /* Кнопка-переключатель в «нажатом» состоянии (меню закреплено). */
    .studio-app .editor-icon-btn.active {
      color: var(--editor-primary);
      border-color: color-mix(in srgb, var(--editor-primary) 45%, transparent);
      background: color-mix(in srgb, var(--editor-primary) 14%, transparent);
    }

    .studio-brand { padding: 16px 16px 12px; display: flex; align-items: center; gap: 12px; min-width: 0; }
    .studio-brand-text { min-width: 0; flex: 1 1 auto; }
    .studio-brand-mark {
      width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
      display: grid; place-items: center; color: #fff; font-size: 15px;
      background: linear-gradient(140deg, var(--editor-primary), var(--editor-accent));
    }
    .studio-brand-mark--sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; font-size: 13px; }
    .studio-brand-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
    .studio-brand-sub { margin-top: 2px; font-size: 11.5px; color: var(--editor-text-muted); line-height: 1.3; }

    .studio-pass-wrap { position: relative; display: block; }
    .studio-pass-wrap input { padding-right: 38px; }
    .studio-pass-toggle {
      position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
      width: 28px; height: 28px; border-radius: 7px; border: 0;
      display: inline-flex; align-items: center; justify-content: center;
      color: var(--editor-text-muted); background: transparent; cursor: pointer;
    }
    .studio-pass-toggle:hover { background: var(--editor-soft-bg-strong); color: var(--editor-text); }

    .studio-nav { padding: 0 8px 12px; }

    /* Группа: заголовок с разрядкой и счётчиком. */
    .studio-group-title {
      display: flex; align-items: center; justify-content: space-between;
      padding: 16px 10px 6px; gap: 8px;
      font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
      color: var(--editor-text-muted);
    }
    .studio-group-count {
      padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 600;
      background: var(--editor-soft-bg-strong); color: var(--editor-text-muted);
      letter-spacing: 0;
    }

    /* Пункт меню: плитка иконки, название, подсказка, счётчик запросов. */
    .studio-item {
      position: relative;
      display: flex; align-items: center; gap: 10px; width: 100%;
      padding: 8px 10px;
      border: 1px solid transparent; border-radius: var(--editor-radius-sm);
      background: transparent; color: var(--editor-text); text-align: left;
      transition: background-color .12s ease, color .12s ease;
    }
    .studio-item + .studio-item { margin-top: 1px; }
    .studio-item:hover { background: var(--editor-row-hover-bg); }
    .studio-item-icon {
      flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px;
      display: grid; place-items: center; font-size: 12.5px;
      background: var(--editor-soft-bg); color: var(--editor-text-muted);
      transition: background-color .12s ease, color .12s ease;
    }
    .studio-item-text { min-width: 0; flex: 1 1 auto; }
    .studio-item-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .studio-item-hint { margin-top: 1px; font-size: 11.5px; line-height: 1.3; color: var(--editor-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .studio-item:hover .studio-item-icon { color: var(--editor-text); }

    .studio-item.active { background: var(--editor-row-active-bg); }
    .studio-item.active::before {
      content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px;
      border-radius: 999px; background: var(--editor-primary);
    }
    .studio-item.active .studio-item-icon { background: var(--editor-primary); color: #fff; }
    .studio-item.active .studio-item-title { color: var(--editor-text-strong); }
    .studio-item:focus-visible { outline: 2px solid var(--editor-primary); outline-offset: 1px; }

    .studio-nav-badge {
      flex: 0 0 auto; min-width: 20px; padding: 1px 6px; border-radius: 999px;
      font-size: 10.5px; font-weight: 700; text-align: center;
      background: var(--editor-warning); color: #1b1206;
    }

    .studio-sidebar-foot {
      display: flex; align-items: center; gap: 8px;
      padding: 12px; border-top: 1px solid var(--editor-line);
    }
    .studio-foot-btn { flex: 1 1 auto; min-width: 0; }
    .studio-foot-icon { flex: 0 0 auto; }

    .studio-role-chip {
      display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px;
      border-radius: 999px; font-size: 10.5px; font-weight: 600;
      border: 1px solid var(--editor-soft-border-strong);
    }
    .studio-role-chip.is-guest { color: var(--editor-warning); border-color: color-mix(in srgb, var(--editor-warning) 40%, transparent); background: color-mix(in srgb, var(--editor-warning) 10%, transparent); }
    .studio-role-chip.is-admin { color: var(--editor-accent); border-color: color-mix(in srgb, var(--editor-accent) 36%, transparent); background: color-mix(in srgb, var(--editor-accent) 8%, transparent); }

    /* ── рабочая область ──────────────────────────────────────────── */
    /* Видимость шапок задаёт сама оболочка, а не Tailwind-классы
       hidden/md:flex в разметке: studio-shell.css подключён после
       tailwind.css, поэтому его display:flex «перебивал» hidden — на
       телефоне десктопная панель показывалась поверх мобильной, сжималась
       в одну строку и кнопки налезали друг на друга (Ctrl K, EN/RU, …). */
    .studio-workbar {
      min-height: 60px; padding: 0 18px;
      background: var(--editor-surface);
      border-bottom: 1px solid var(--editor-line);
      display: none; align-items: center; justify-content: space-between; gap: 16px;
      min-width: 0;
    }
    .studio-workbar > * { min-width: 0; }
    .studio-workbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
    .studio-workbar-actions .editor-btn { white-space: nowrap; }
    .studio-workbar-title { font-size: 14.5px; font-weight: 650; letter-spacing: -.005em; line-height: 1.25; }
    .studio-workbar-meta { margin-top: 1px; font-size: 11.5px; color: var(--editor-text-muted); line-height: 1.3; }
    @media (min-width: 768px) { .studio-workbar { display: flex; } }
    @media (max-width: 1100px) {
      .studio-workbar { padding: 0 12px; gap: 10px; }
      .studio-workbar .studio-kbd { display: none; }
    }

    .studio-mobile-bar {
      min-height: 56px; padding: 0 12px;
      background: var(--editor-surface); border-bottom: 1px solid var(--editor-line);
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      min-width: 0;
    }
    @media (min-width: 768px) { .studio-mobile-bar { display: none; } }
    .studio-mobile-title { font-size: 14px; font-weight: 650; min-width: 0; }

    .studio-loading {
      position: absolute; z-index: 5; left: 0; right: 0; top: 0; height: 2px;
      overflow: hidden; opacity: 0; transition: opacity .15s ease;
    }
    .studio-loading::after {
      content: ''; display: block; width: 32%; height: 100%;
      background: var(--editor-primary);
      animation: studioLoad 1.1s ease-in-out infinite;
    }
    .studio-loading.active { opacity: 1; }
    @keyframes studioLoad { from { transform: translateX(-110%); } to { transform: translateX(360%); } }

    /* ── вход ─────────────────────────────────────────────────────── */
    .studio-auth-card {
      position: relative;
      width: 100%; max-width: 420px;
      background: var(--editor-surface);
      border: 1px solid var(--editor-line-strong);
      border-radius: var(--editor-radius-lg);
      box-shadow: var(--editor-shadow-lg);
      padding: 24px;
    }
    .studio-auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
    .studio-auth-icon {
      width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
      display: grid; place-items: center; font-size: 14px;
      background: color-mix(in srgb, var(--editor-accent) 14%, transparent);
      border: 1px solid color-mix(in srgb, var(--editor-accent) 28%, transparent);
      color: var(--editor-accent);
    }
    .studio-auth-card h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
    .studio-auth-field { display: block; }
    .studio-auth-field + .studio-auth-field { margin-top: 12px; }
    .studio-auth-field > span { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 600; color: var(--editor-text-muted); }
    .auth-tabs {
      display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
      border-radius: var(--editor-radius-md);
      background: var(--editor-soft-bg); border: 1px solid var(--editor-line);
    }
    .auth-tab {
      height: 32px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
      color: var(--editor-text-muted); display: inline-flex; align-items: center;
      justify-content: center; gap: 6px; border: 0; background: transparent;
    }
    .auth-tab:hover { color: var(--editor-text); }
    .auth-tab.active { background: var(--editor-surface-2); color: var(--editor-text); box-shadow: 0 0 0 1px var(--editor-line-strong); }
    .auth-tab:disabled { opacity: .45; cursor: not-allowed; }
    .auth-guest-note {
      border: 1px solid color-mix(in srgb, var(--editor-warning) 30%, transparent);
      background: color-mix(in srgb, var(--editor-warning) 8%, transparent);
      border-radius: var(--editor-radius-md); padding: 10px 12px;
      font-size: 12.5px; line-height: 1.5; color: var(--editor-text);
    }
    .auth-guest-note b { font-weight: 600; }

    .studio-scrim { background: color-mix(in srgb, #05080f 72%, transparent); backdrop-filter: blur(2px); }

    .auth-status { margin-top: 12px; font-size: var(--editor-text-sm); line-height: 1.45; }
    .auth-status.is-ok { color: var(--editor-success); }
    .auth-status.is-err { color: var(--editor-danger); }

    @media (prefers-reduced-motion: reduce) {
      .studio-item, .studio-item:hover, .studio-loading::after { transition: none; animation: none; }
      .studio-sidebar, .studio-sidebar__panel { transition: none; }
    }


/* ── keep-alive вкладки редакторов ────────────────────────────────────────
   Каждый открытый редактор — свой iframe; неактивные просто скрыты, поэтому
   переключение мгновенно и не теряет несохранённое состояние формы. */
.studio-frames { position: absolute; inset: 0; }
.studio-frames .studio-iframe { position: absolute; inset: 0; }
.studio-frames .studio-iframe[hidden] { display: none; }

/* Полоса открытых вкладок над рабочей областью. */
.studio-tabs {
  display: flex; align-items: stretch; gap: 2px;
  padding: 6px 10px 0; overflow-x: auto; scrollbar-width: thin;
  background: var(--editor-surface); border-bottom: 1px solid var(--editor-line);
}
.studio-tabs:empty { display: none; }
.studio-tab {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  max-width: 220px; padding: 7px 8px 7px 11px;
  border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0;
  background: transparent; color: var(--editor-text-muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.studio-tab:hover { background: var(--editor-row-hover-bg); color: var(--editor-text); }
.studio-tab.active {
  background: var(--editor-bg); color: var(--editor-text);
  border-color: var(--editor-line);
  box-shadow: inset 0 2px 0 var(--editor-primary);
}
.studio-tab-open { display: inline-flex; align-items: center; gap: 7px; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.studio-tab-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-tab-close {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 18px; height: 18px; border: 0; border-radius: 5px;
  background: transparent; color: inherit; font-size: 10px; cursor: pointer; opacity: .7;
}
.studio-tab-close:hover { background: var(--editor-soft-bg-strong); opacity: 1; }

/* ── поиск и избранное в меню ─────────────────────────────────────────── */
.studio-nav-filter { padding: 2px 12px 10px; }
.studio-nav-filter .editor-search { width: 100%; }
.studio-sidebar.is-rail .studio-nav-filter,
.studio-sidebar.is-rail .studio-fav-btn { display: none; }
.studio-item-wrap { display: flex; align-items: center; }
.studio-item-wrap + .studio-item-wrap { margin-top: 1px; }
.studio-item-wrap .studio-item { flex: 1 1 auto; min-width: 0; }
.studio-fav-btn {
  flex: 0 0 auto; width: 28px; height: 28px; margin-right: 2px;
  display: grid; place-items: center; border: 0; border-radius: 7px;
  background: transparent; color: var(--editor-text-muted); font-size: 11px; cursor: pointer;
  opacity: 0; transition: opacity .12s ease, color .12s ease, background-color .12s ease;
}
.studio-item-wrap:hover .studio-fav-btn,
.studio-fav-btn:focus-visible,
.studio-fav-btn.is-fav { opacity: 1; }
.studio-fav-btn:hover { background: var(--editor-soft-bg-strong); color: var(--editor-text); }
.studio-fav-btn.is-fav { color: var(--editor-warning); }

/* ── палитра команд (Ctrl+K) ──────────────────────────────────────────── */
.studio-palette-backdrop {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  background: color-mix(in srgb, #05080f 66%, transparent);
  backdrop-filter: blur(2px);
}
.studio-palette {
  width: min(620px, 100%); max-height: 64vh; display: flex; flex-direction: column;
  background: var(--editor-elevated-bg); border: 1px solid var(--editor-line-strong);
  border-radius: var(--editor-radius-lg); box-shadow: var(--editor-shadow-lg);
  overflow: hidden;
}
.studio-palette-input {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--editor-line);
  color: var(--editor-text-muted);
}
.studio-palette-input input {
  flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--editor-text); font: inherit; font-size: 15px;
}
.studio-palette-list { overflow-y: auto; padding: 6px; }
.studio-palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--editor-text); text-align: left; cursor: pointer;
}
.studio-palette-item .studio-item-icon { flex-basis: 28px; width: 28px; height: 28px; }
.studio-palette-item.is-selected { background: var(--editor-row-active-bg); }
.studio-palette-meta { margin-left: auto; flex: 0 0 auto; font-size: 11px; color: var(--editor-text-muted); }
.studio-palette-empty { padding: 22px; text-align: center; color: var(--editor-text-muted); font-size: 13px; }
.studio-palette-foot {
  display: flex; gap: 14px; padding: 8px 12px;
  border-top: 1px solid var(--editor-line);
  font-size: 11px; color: var(--editor-text-muted);
}
.studio-kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--editor-line-strong); border-bottom-width: 2px;
  background: var(--editor-soft-bg); color: var(--editor-text);
  font-family: var(--editor-font-mono); font-size: 11px; line-height: 1.5;
}

/* ── настройки внешнего вида ──────────────────────────────────────────── */
/* Не перекрываем overflow:auto у .editor-modal-content: длинное окно на
   маленьком экране должно прокручиваться, а не обрезаться. */
.studio-prefs-card { position: relative; }
.studio-prefs-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 96px; pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--editor-primary) 14%, transparent), transparent 100%);
  opacity: .85;
}
.studio-prefs-card > * { position: relative; }

.studio-prefs-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding-bottom: 16px; margin-bottom: 18px;
  border-bottom: 1px solid var(--editor-line);
}
.studio-prefs-head-icon {
  flex: 0 0 38px; width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--editor-radius-md); font-size: 15px;
  color: var(--editor-primary);
  background: color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--editor-primary) 32%, transparent);
}
.studio-prefs-head-text { min-width: 0; flex: 1 1 auto; }
.studio-prefs-head-text h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
.studio-prefs-hint { margin: 4px 0 0; font-size: 12px; line-height: 1.5; color: var(--editor-text-muted); }

.studio-prefs-section {
  padding: 13px 14px 14px;
  border: 1px solid var(--editor-line);
  border-radius: var(--editor-radius-md);
  background: var(--editor-soft-bg);
}
.studio-prefs-section + .studio-prefs-section { margin-top: 10px; }
.studio-prefs-section-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 13px; font-weight: 650; color: var(--editor-text);
}
.studio-prefs-section-head > i {
  width: 20px; height: 20px; display: grid; place-items: center;
  border-radius: 6px; font-size: 10px;
  color: var(--editor-primary);
  background: color-mix(in srgb, var(--editor-primary) 12%, transparent);
}
.studio-prefs-section-note { margin: 9px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--editor-text-muted); }

.studio-seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--editor-soft-bg-strong); border: 1px solid var(--editor-line); flex-wrap: wrap; }
.studio-seg-btn {
  height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--editor-text-muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.studio-seg-btn:hover { color: var(--editor-text); background: var(--editor-soft-bg-strong); }
.studio-seg-btn.active {
  background: color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--editor-primary) 42%, transparent);
  color: var(--editor-text-strong);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.studio-seg-btn.active i { color: var(--editor-primary); }
.studio-seg-btn:focus-visible { outline: 2px solid var(--editor-primary); outline-offset: 2px; }

/* Цвет задаётся инлайн-переменной из каталога акцентов: так все образцы
   видны сразу, а новый акцент не требует правки селекторов в CSS. */
.studio-swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
@media (max-width: 480px) {
  .studio-swatches { grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); }
}
.studio-swatch {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 4px 7px;
  border: 1px solid var(--editor-line); border-radius: 10px;
  background: var(--editor-surface-2); color: var(--editor-text-muted);
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background-color .14s ease, box-shadow .14s ease, color .14s ease;
}
.studio-swatch:hover {
  transform: translateY(-1px); color: var(--editor-text);
  border-color: color-mix(in srgb, var(--swatch-color) 55%, transparent);
}
.studio-swatch:focus-visible { outline: 2px solid var(--editor-primary); outline-offset: 2px; }
.studio-swatch-dot {
  width: 24px; height: 24px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--swatch-color, var(--editor-primary));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22),
              0 3px 8px color-mix(in srgb, var(--swatch-color, var(--editor-primary)) 32%, transparent);
  color: #fff; font-size: 10px;
}
.studio-swatch-check { opacity: 0; transform: scale(.6); transition: opacity .14s ease, transform .14s ease; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.studio-swatch-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 600; line-height: 1.2; }
.studio-swatch.active {
  background: color-mix(in srgb, var(--swatch-color) 12%, transparent);
  border-color: color-mix(in srgb, var(--swatch-color) 62%, transparent);
  color: var(--editor-text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--swatch-color) 24%, transparent);
}
.studio-swatch.active .studio-swatch-check { opacity: 1; transform: scale(1); }

.studio-prefs-preview {
  margin-top: 12px; padding: 11px 13px 13px;
  border: 1px solid var(--editor-line); border-radius: var(--editor-radius-md);
  background: var(--editor-surface);
}
.studio-prefs-preview-label { display: block; margin-bottom: 9px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--editor-text-muted); }
.studio-prefs-preview-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.studio-prefs-preview-row .editor-btn { min-height: 30px; padding: 0 12px; font-size: 11.5px; pointer-events: none; }
.studio-prefs-preview-row-item {
  padding: 5px 10px; border-radius: var(--editor-radius-sm);
  font-size: 11.5px; font-weight: 600; color: var(--editor-text);
  background: color-mix(in srgb, var(--editor-primary) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--editor-primary) 42%, transparent);
  box-shadow: inset 2px 0 0 var(--editor-primary);
}

/* ── доступность ──────────────────────────────────────────────────────── */
.studio-skip {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  padding: 9px 14px; border-radius: 9px;
  background: var(--editor-primary); color: #fff; font-weight: 600; font-size: 13px;
  transition: top .15s ease;
}
.studio-skip:focus-visible { top: 12px; color: #fff; }
.studio-caps { margin-top: 8px; font-size: 12.5px; color: var(--editor-warning); display: flex; align-items: center; gap: 6px; }
.studio-caps[hidden] { display: none; }

.studio-shortcuts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.studio-shortcuts dt { text-align: right; }
.studio-shortcuts dd { color: var(--editor-text-muted); }

/* Collapsible menu groups */
button.studio-group-title { width: 100%; background: transparent; border: 0; cursor: pointer; font: inherit; text-align: left; }
.studio-group-meta { display: inline-flex; align-items: center; gap: 6px; }
.studio-group-chev { font-size: 9px; color: var(--editor-text-muted); transition: transform .15s ease; }
.studio-group-title.is-collapsed .studio-group-chev { transform: rotate(-90deg); }
.studio-group-title.is-collapsed + .studio-group-items { display: none; }
.studio-sidebar.is-rail .studio-group-chev { display: none; }
.studio-sidebar.is-rail .studio-group-title.is-collapsed + .studio-group-items { display: block; }

/* Tabs: restored-but-not-loaded editor, drag reorder */
.studio-tab.is-lazy .studio-tab-open, .studio-tab.is-lazy .studio-tab-close { opacity: .65; }
.studio-tab.is-dragging { opacity: .45; }
.studio-tab.is-drop-before { box-shadow: inset 2px 0 0 var(--editor-primary); }
.studio-tab.is-drop-after { box-shadow: inset -2px 0 0 var(--editor-primary); }

/* ── узкие экраны: вкладки, выдвижное меню, окно входа ───────────────────
   Полоса вкладок и так прокручивается, но вкладка по 220px на телефоне
   съедала почти весь экран — ужимаем её, а меню и карточку входа не даём
   выйти за вьюпорт (включая вырезы/безопасные зоны). */
.studio-tabs { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.studio-frames, .studio-frames .studio-iframe { min-width: 0; }
@media (max-width: 767px) {
  .studio-tab { max-width: 156px; padding: 6px 6px 6px 9px; font-size: 12px; }
  .studio-tabs { padding: 6px 6px 0; }
  .studio-drawer {
    width: min(320px, 88vw); height: 100%; height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .studio-auth-card { padding: 18px 16px; }
  .studio-shortcuts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .studio-shortcuts dt { text-align: left; margin-top: 8px; }
}
@media (max-width: 420px) {
  .studio-tab { max-width: 132px; }
  .studio-mobile-bar { padding: 0 8px; gap: 8px; }
}

/* Sidebar width handle */
.studio-resizer { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 6; touch-action: none; }
.studio-resizer:hover { background: color-mix(in srgb, var(--editor-primary) 35%, transparent); }
.studio-sidebar.is-rail .studio-resizer { display: none; }
.studio-drag-shield { position: fixed; inset: 0; z-index: 999; cursor: col-resize; }
