/* ========================================================================
   CoopLoop Панель v2 — app_v2.css · CK-LK2-REDESIGN-V2 (2026-10-03)
   Слой редизайна ПОВЕРХ app.css (грузится после него): палитра Slate/Emerald,
   B2G/CRM-стилистика (мягкие карточки, ровные радиусы, рассеянные тени),
   сплит-«Студия бота». app.css не переписан — откат = убрать <link> в index.html.

   Правило app.css сохраняется: в компонентах нет hex — только var(...).
   Hex живут в двух блоках токенов ниже (светлая / тёмная тема).
   Контраст (WCAG AA): текст на акценте и акцентный текст — через --accent-strong
   (#047857 на белом = 5.5:1); #059669 — для заливок-маркеров, рамок и колец.
   ======================================================================== */

/* ---------- Токены: светлая тема ---------- */
:root {
  --bg: #f8fafc;          --surface: #ffffff;    --surface-2: #f1f5f9;
  --border: #e2e8f0;      --border-strong: #cbd5e1;
  --text: #0f172a;        --text-2: #475569;     --text-3: #64748b;
  --accent: #059669;      --accent-weak: #ecfdf5;  --on-accent: #ffffff;
  --accent-strong: #047857;  --accent-hover: #065f46;
  --accent-ring: rgba(5, 150, 105, .22);
  --ok: #059669;   --ok-weak: #ecfdf5;
  --warn: #b45309; --warn-weak: #fffbeb;
  --danger: #dc2626; --danger-weak: #fef2f2;
  --info: #1d4ed8; --info-weak: #eff6ff; --info-border: #bfdbfe;
  --font: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-full: 9999px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 20px -2px rgba(15, 23, 42, .06);
  --shadow-2: 0 12px 40px -8px rgba(15, 23, 42, .18);
  /* Студия */
  --stage-bg: #f1f5f9;
  --chat-bg: #e9eef4;
  --chat-dots: rgba(15, 23, 42, .045);
  --phone-bezel: #0f172a;  --phone-edge: #334155;
  --key-bg: #ffffff;  --key-border: #dbe3ec;  --key-text: #047857;
  --c-folder: #b7791f; --c-link: #2563eb; --c-action: #7c3aed; --c-internal: #0e7490;
  --tt-bg: #0f172a; --tt-fg: #f8fafc;
}

/* ---------- Токены: тёмная тема (система и ручной выбор — держать синхронно) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17;          --surface: #131b26;    --surface-2: #1e293b;
    --border: #273449;      --border-strong: #334155;
    --text: #f8fafc;        --text-2: #94a3b8;     --text-3: #8391a7;
    --accent: #10b981;      --accent-weak: rgba(16, 185, 129, .12);  --on-accent: #052e1c;
    --accent-strong: #34d399;  --accent-hover: #6ee7b7;
    --accent-ring: rgba(16, 185, 129, .3);
    --ok: #10b981; --ok-weak: rgba(16, 185, 129, .12);
    --warn: #fbbf24; --warn-weak: rgba(251, 191, 36, .12);
    --danger: #f87171; --danger-weak: rgba(248, 113, 113, .12);
    --info: #93c5fd; --info-weak: rgba(96, 165, 250, .12); --info-border: rgba(96, 165, 250, .32);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px -2px rgba(0, 0, 0, .35);
    --shadow-2: 0 16px 48px -8px rgba(0, 0, 0, .6);
    --stage-bg: #0f1621;
    --chat-bg: #0b1220;
    --chat-dots: rgba(148, 163, 184, .06);
    --phone-bezel: #020617;  --phone-edge: #334155;
    --key-bg: #1a2433;  --key-border: #2b3a50;  --key-text: #6ee7b7;
    --c-folder: #fbbf24; --c-link: #60a5fa; --c-action: #a78bfa; --c-internal: #22d3ee;
    --tt-bg: #e2e8f0; --tt-fg: #0f172a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;          --surface: #131b26;    --surface-2: #1e293b;
  --border: #273449;      --border-strong: #334155;
  --text: #f8fafc;        --text-2: #94a3b8;     --text-3: #8391a7;
  --accent: #10b981;      --accent-weak: rgba(16, 185, 129, .12);  --on-accent: #052e1c;
  --accent-strong: #34d399;  --accent-hover: #6ee7b7;
  --accent-ring: rgba(16, 185, 129, .3);
  --ok: #10b981; --ok-weak: rgba(16, 185, 129, .12);
  --warn: #fbbf24; --warn-weak: rgba(251, 191, 36, .12);
  --danger: #f87171; --danger-weak: rgba(248, 113, 113, .12);
  --info: #93c5fd; --info-weak: rgba(96, 165, 250, .12); --info-border: rgba(96, 165, 250, .32);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px -2px rgba(0, 0, 0, .35);
  --shadow-2: 0 16px 48px -8px rgba(0, 0, 0, .6);
  --stage-bg: #0f1621;
  --chat-bg: #0b1220;
  --chat-dots: rgba(148, 163, 184, .06);
  --phone-bezel: #020617;  --phone-edge: #334155;
  --key-bg: #1a2433;  --key-border: #2b3a50;  --key-text: #6ee7b7;
  --c-folder: #fbbf24; --c-link: #60a5fa; --c-action: #a78bfa; --c-internal: #22d3ee;
  --tt-bg: #e2e8f0; --tt-fg: #0f172a;
}

/* ---------- База и иконки ---------- */
body { letter-spacing: -.003em; transition: background-color .2s ease, color .2s ease; }
.ico { display: block; flex: none; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
a { color: var(--accent-strong); }
:focus-visible { outline-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }

/* ---------- Оболочка ---------- */
.topbar { box-shadow: 0 1px 0 var(--border); border-bottom-color: transparent; }
.topbar-badge { border-radius: 10px; background: var(--accent-strong); }
#themeToggle .theme-icon { display: inline-flex; }
@media (min-width: 640px) and (max-width: 1023px) { #navToggle { display: inline-flex; } }
.sidebar { padding: 14px 10px; }
.nav-item { font-weight: 500; color: var(--text-2); border-radius: 10px; padding: 9px 12px; }
.nav-item:hover { color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent-strong); font-weight: 600; }
.nav-ico { display: inline-flex; align-items: center; justify-content: center; color: inherit; }
.nav-cat-head { font-weight: 600; color: var(--text); }
.nav-cat-ico, .nav-cat-chevron, .nav-cat-toggleall-ico { display: inline-flex; color: var(--text-3); }
.nav-cat-body { border-left-color: var(--border); }
.main { background: var(--bg); }

/* ---------- Кнопки и контролы (Bitrix-стиль: ровно, мягко, без «пластмассы») ---------- */
.btn { border-radius: var(--r-s); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background-color .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--accent-strong); }
.btn-primary:hover { background: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { background: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: var(--accent); } }
.btn-outline { border-color: var(--accent); color: var(--accent-strong); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; border-radius: var(--r-s); color: var(--text-2);
  transition: background-color .15s, color .15s;
}
.icon-btn.on { background: var(--accent-weak); color: var(--accent-strong); }
.inp, select.inp, textarea.inp { border-radius: var(--r-s); border-color: var(--border); background: var(--surface); }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.segmented { background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--border); }
.segmented-item { display: inline-flex; align-items: center; gap: 6px; border-radius: 7px; font-weight: 500; }
.segmented-item.on { background: var(--surface); color: var(--accent-strong); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.segmented-item.is-disabled { opacity: .45; cursor: not-allowed; }
.seg-ico { display: inline-flex; }
.card { border-radius: var(--r-l); box-shadow: var(--shadow-1); border-color: var(--border); }
.modal, .slideover { border-radius: var(--r-l); }
.slideover { border-radius: 0; }
.toast { border-radius: 10px; box-shadow: var(--shadow-2); }
.badge { font-weight: 600; }
.empty-state-ico { color: var(--text-3); opacity: 1; display: flex; justify-content: center; }

/* ---------- Тултипы (core/tooltip.js) ---------- */
.tt {
  position: fixed; z-index: 200; top: 0; left: 0; max-width: 280px; pointer-events: none;
  padding: 6px 10px; border-radius: 8px; background: var(--tt-bg); color: var(--tt-fg);
  font-size: 12px; line-height: 1.4; font-weight: 500; box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(3px); transition: opacity .14s ease, transform .14s ease;
}
.tt.below { transform: translateY(-3px); }
.tt.on { opacity: 1; transform: none; }

/* ---------- Пилюли и маркеры ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 3px; flex: none; height: 18px; padding: 0 7px;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2);
  font-size: 10.5px; font-weight: 600; white-space: nowrap; max-width: 120px; overflow: hidden;
}
.pill > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.pill-ico { padding: 0 4px; }
.pill-warn { background: var(--warn-weak); color: var(--warn); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box;
  border: 1.5px solid var(--border-strong); background: transparent;
}
.status-dot.is-on { border: none; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }

/* ══════════════════════ Студия бота (#menu) ══════════════════════ */

/* Шапка вью: заголовок + бейдж «в разработке» */
.studio-head-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.dev-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px;
  border-radius: var(--r-full); background: var(--info-weak); color: var(--info);
  border: 1px solid var(--info-border); font-size: 12px; font-weight: 600; cursor: help; white-space: nowrap;
}
.studio-sub { margin-bottom: 14px; }

/* Раскладка. Сплит включает JS (.is-split по ширине рабочей области, SPLIT_MIN). */
.studio-wrap { display: block; min-width: 0; }
.studio-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.studio-tree-col { display: none; min-width: 0; min-height: 0; }
.studio-wrap.is-split .studio-split { grid-template-columns: clamp(300px, 36%, 400px) minmax(0, 1fr); }
.studio-wrap.is-split .studio-tree-col { display: flex; }
.studio-wrap.is-split.no-tree .studio-split { grid-template-columns: minmax(0, 1fr); }
.studio-wrap.is-split.no-tree .studio-tree-col { display: none; }
/* app.css прятал дерево по ширине ОКНА (<1024) — в сплите оно видно всегда. */
.studio-wrap.is-split .menu-tree { display: flex; }
.studio-wrap .menu-tree { display: flex; }

/* Заполнение экрана: в сплите вью = высота окна, колонки скроллятся независимо,
   телефон всегда на виду (sticky внутри .main не работал: .main — свой скролл-контейнер). */
body.studio-fill .main { height: calc(100vh - 56px); height: calc(100dvh - 56px); display: flex; flex-direction: column; overflow: hidden; padding-top: 18px; padding-bottom: 16px; }
body.studio-fill .main > .view-head, body.studio-fill .main > .studio-sub { flex: none; }
body.studio-fill .studio-wrap { flex: 1; min-height: 0; }
body.studio-fill .studio-split { height: 100%; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
/* Длинный сайдбар не должен давать прокрутку документа: в студии у него свой скролл. */
@media (min-width: 1024px) {   /* <1024 сайдбар выезжающий (fixed) — его не трогаем */
  body.studio-fill .sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); height: calc(100dvh - 56px); overflow-y: auto; scrollbar-width: thin; }
}
@media (max-height: 800px) { body.studio-fill .studio-sub { display: none; } body.studio-fill .main > .view-head { margin-bottom: 12px; } }
body.studio-fill .studio-stage { min-height: 0; }

/* ── Левая колонка: дерево ── */
.menu-tree {
  flex: 1; flex-direction: column; min-height: 0; min-width: 0; padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-1);
}
.menu-tree-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none;
  padding: 12px 12px 10px 16px; margin: 0; border-bottom: none;
}
.menu-tree-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--text); }
.menu-tree-title .ic { color: var(--text-3); }
.menu-tree-count {
  font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  border-radius: var(--r-full); padding: 1px 8px;
}
.menu-tree-tools { display: flex; gap: 2px; }
.menu-tree-searchbox {
  display: flex; align-items: center; gap: 8px; flex: none; margin: 0 12px 8px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-s); background: var(--surface-2); color: var(--text-3);
}
.menu-tree-searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.menu-tree-search.inp { border: none; background: transparent; box-shadow: none; padding: 7px 0; flex: 1; min-width: 0; font-size: 13px; }
.menu-tree-search.inp:focus { box-shadow: none; }
.menu-tree-list {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 0;
  padding: 4px 8px 12px; border-top: 1px solid var(--border); scrollbar-width: thin;
}
.studio-wrap:not(.is-split) .menu-tree-list, body:not(.studio-fill) .menu-tree-list { max-height: 72vh; }
.menu-tree-nothing { padding: 14px 8px; text-align: center; }

.menu-node {
  display: flex; align-items: center; gap: 6px; position: relative; min-height: 34px;
  padding: 0 4px 0 4px; border-radius: var(--r-s); cursor: pointer; user-select: none;
  color: var(--text); transition: background-color .12s;
}
.menu-node:hover { background: var(--surface-2); }
.menu-node.on { background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }
.menu-node.on .menu-node-title { font-weight: 600; color: var(--text); }
.menu-node.draft { opacity: 1; }
.menu-node.draft .menu-node-title { color: var(--text-2); }
.menu-node.on.pulse { animation: tree-pulse 1.1s ease-out; }
@keyframes tree-pulse { 0% { background: var(--accent-ring); } 100% { background: var(--accent-weak); } }
.menu-node-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.menu-node-ico { display: inline-flex; flex: none; color: var(--text-2); }
.menu-node-ico.t-folder { color: var(--c-folder); }
.menu-node-ico.t-link { color: var(--c-link); }
.menu-node-ico.t-action { color: var(--c-action); }
.menu-node-ico.t-internal { color: var(--c-internal); }
.menu-node-tog {
  width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-3); border-radius: 5px; padding: 0; cursor: pointer;
  transition: transform .15s ease, background-color .12s;
}
.menu-node-tog:hover { background: var(--border); color: var(--text); }
.menu-node.open .menu-node-tog { transform: rotate(90deg); }
.menu-node-tog.is-empty { pointer-events: none; }
.menu-node-count {
  flex: none; min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.menu-node.on .menu-node-count { background: var(--surface); }
.menu-node-pub { display: none; }
.menu-node-menu { opacity: 0; min-width: 26px; height: 26px; }
.menu-node:hover .menu-node-menu, .menu-node.on .menu-node-menu, .menu-node-menu:focus-visible { opacity: 1; }

/* Направляющие уровней: сквозная вертикаль, пока ветка продолжается, + «локоть». */
.tg-wrap { display: flex; align-self: stretch; flex: none; }
.tg { position: relative; width: 18px; flex: none; }
.tg-line::before, .tg-elbow::before {
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0; border-left: 1px solid var(--border-strong);
}
.tg-elbow.tg-last::before { bottom: 50%; }
.tg-elbow::after { content: ''; position: absolute; left: 8px; right: 2px; top: 50%; border-top: 1px solid var(--border-strong); }

/* DnD дерева — подсказки Д2-9 в новой палитре */
.menu-node.dnd-over-inside { outline: 2px dashed var(--accent); background: var(--accent-weak); }
.menu-node.dnd-over-before::before, .menu-node.dnd-over-after::after { background: var(--accent); }

/* Дерево в шторке (узко) */
.slideover .menu-tree { border: none; box-shadow: none; border-radius: 0; overflow: visible; }
.slideover .menu-tree-list { max-height: none; overflow: visible; border-top: none; padding: 4px 0; }
.slideover .menu-tree-head { padding-left: 4px; padding-right: 0; }
.slideover .menu-tree-searchbox { margin-left: 0; margin-right: 0; }
.slideover .menu-node { min-height: 42px; }
.slideover .menu-node-menu { opacity: 1; }

/* ── Правая колонка: сцена эмулятора ── */
.studio-stage {
  display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden;
  background: var(--stage-bg); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-1);
  container-type: inline-size; container-name: stage;
}
.studio-stage.is-loading .studio-viewport { opacity: .6; transition: opacity .12s; }
.studio-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; margin: 0;
  padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.studio-toolbar .btn.on { background: var(--accent-weak); color: var(--accent-strong); }
.studio-tree-btn { gap: 6px; }
.studio-toolbar .segmented-item { padding: 5px 10px; font-size: 12.5px; }
.studio-mode-seg .segmented-item.on[data-v="edit"] { color: var(--accent-strong); }
@container stage (max-width: 640px) {
  .studio-tb-label, .studio-toolbar .segmented-item .seg-ico + span { display: none; }
  .studio-toolbar .segmented-item { padding: 6px 9px; }
}
.studio-wrap.is-split:not(.no-tree) .studio-tree-btn { display: none; }

.studio-viewport {
  flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  padding: 24px 16px 28px;
  background-image: radial-gradient(var(--chat-dots) 1px, transparent 1px); background-size: 18px 18px;
}
body.studio-fill .studio-viewport { align-items: stretch; padding: 16px 16px 18px; }

/* ── Девайс: рама смартфона (iPhone-style) ── */
.studio-device {
  position: relative; margin: 0 auto; width: 100%; display: flex; flex-direction: column;
  background: var(--chat-bg); border: none; overflow: hidden; transition: max-width .2s ease;
}
.studio-device.is-mobile {
  width: 375px; max-width: 100%; border-radius: 44px; flex: none;
  box-shadow: 0 0 0 9px var(--phone-bezel), 0 0 0 10px var(--phone-edge), 0 28px 60px -16px rgba(15, 23, 42, .45);
  margin: 10px auto;
}
body.studio-fill .studio-device.is-mobile { height: calc(100% - 20px); max-height: 812px; min-height: 0; }
body:not(.studio-fill) .studio-device.is-mobile .studio-chat { min-height: 420px; }
.studio-device.is-pc {
  max-width: 760px; border-radius: 12px; border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
}
body.studio-fill .studio-device.is-pc { height: 100%; max-height: 900px; }
body:not(.studio-fill) .studio-device.is-pc .studio-chat { min-height: 380px; }

.phone-island {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%); z-index: 3;
  width: 104px; height: 30px; border-radius: var(--r-full); background: var(--phone-bezel);
}
.phone-status {
  display: flex; align-items: center; justify-content: space-between; flex: none;
  height: 50px; padding: 6px 30px 0 34px; background: var(--surface); color: var(--text);
}
.phone-time { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.phone-sys { display: inline-flex; align-items: center; gap: 6px; }
.phone-home {
  flex: none; width: 128px; height: 5px; margin: 6px auto 8px; border-radius: var(--r-full);
  background: var(--text); opacity: .85;
}
.studio-device.is-mobile .studio-composer { padding-bottom: 2px; }
.pc-titlebar {
  display: flex; align-items: center; gap: 7px; flex: none; height: 34px; padding: 0 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.pc-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border-strong); }
.pc-titlebar-name { margin-left: 10px; font-size: 12px; color: var(--text-3); }

/* Шапка чата + крошки */
.studio-chat-top { flex: none; background: var(--surface); border-bottom: 1px solid var(--border); }
.studio-chat-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px 6px; }
.studio-chat-back {
  width: 32px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--accent-strong); border-radius: 50%; cursor: pointer; padding: 0;
}
.studio-chat-back:hover { background: var(--accent-weak); }
.studio-chat-back.is-empty { pointer-events: none; }
.studio-bot-ava {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-strong); color: var(--on-accent); font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
:root[data-theme="dark"] .studio-bot-ava { background: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .studio-bot-ava { background: var(--accent); } }
.studio-bot-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.studio-bot-name { font-weight: 600; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-bot-state { font-size: 12px; color: var(--accent-strong); }
.studio-crumbs {
  display: flex; align-items: center; gap: 2px; padding: 0 10px 8px; font-size: 12px;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.studio-crumbs::-webkit-scrollbar { display: none; }
.studio-crumb {
  display: inline-flex; align-items: center; gap: 5px; flex: none; max-width: 180px; height: 24px; padding: 0 8px;
  border: none; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.studio-crumb span:last-child { overflow: hidden; text-overflow: ellipsis; }
.studio-crumb:hover { background: var(--accent-weak); color: var(--accent-strong); }
.studio-crumb.cur { background: var(--accent-weak); color: var(--accent-strong); font-weight: 600; cursor: default; }
.studio-crumb-sep { display: inline-flex; color: var(--text-3); flex: none; }

/* Лента чата */
.studio-chat {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px 14px; scrollbar-width: thin;
  background-image: radial-gradient(var(--chat-dots) 1px, transparent 1px); background-size: 16px 16px;
}
.studio-day {
  align-self: center; font-size: 11px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border-radius: var(--r-full); padding: 2px 10px; opacity: .9;
}
.studio-msg {
  position: relative; align-self: flex-start; max-width: 94%; min-width: 60%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 18px 6px;
  padding: 10px 12px 18px; box-shadow: 0 1px 1px rgba(15, 23, 42, .05);
}
.studio-device.is-pc .studio-msg { max-width: 78%; }
.studio-msg.editable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.studio-msg-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.studio-msg-slug { font-weight: 400; font-size: 11px; }
.studio-msg-body { font-size: 13.5px; line-height: 1.5; color: var(--text); }
.studio-msg-time { position: absolute; right: 10px; bottom: 4px; font-size: 10.5px; color: var(--text-3); }
.studio-msg-root { min-width: 0; }

/* Клавиатура бота (inline-кнопки) */
.studio-keys, .studio-syskeys { display: flex; flex-direction: column; gap: 6px; }
.studio-krow { display: flex; gap: 6px; }
.studio-key {
  flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; background: var(--key-bg); border: 1px solid var(--key-border); border-radius: 12px;
  color: var(--key-text); font-size: 13.5px; font-weight: 600; cursor: pointer; position: relative;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .04); transition: background-color .12s, border-color .12s, transform .08s;
}
.studio-key:hover { background: var(--accent-weak); border-color: var(--accent); }
.studio-key:active { transform: scale(.99); }
.studio-key.is-link { border-style: solid; }
.studio-key.draft { opacity: .6; border-style: dashed; }
.studio-key.hl { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.studio-key.sys { background: var(--surface-2); color: var(--text-2); font-weight: 500; font-size: 12.5px; min-height: 36px; }
.studio-key.sys:hover { color: var(--accent-strong); }
.studio-key-ico, .studio-key-go { display: inline-flex; opacity: .85; }
.studio-key-go { margin-left: -2px; opacity: .5; }
.studio-key-grip { position: absolute; left: 6px; color: var(--text-3); opacity: 0; }
.studio-key:hover .studio-key-grip { opacity: 1; }
.studio-key-mini { min-width: 22px; width: 22px; height: 22px; opacity: .5; }
.studio-key:hover .studio-key-mini, .studio-msg:hover .studio-key-mini { opacity: 1; }
.studio-addbtn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; background: transparent;
  color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.studio-addbtn:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-weak); }
.studio-sys-sep { font-size: 10.5px; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.grid-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 6px 0; }

/* Поле ввода (декор) */
.studio-composer {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface); border-top: 1px solid var(--border); color: var(--text-3);
}
.composer-input {
  flex: 1; height: 34px; display: flex; align-items: center; padding: 0 14px;
  border-radius: var(--r-full); background: var(--surface-2); font-size: 13px;
}

/* Фокус-режим поверх новой сцены */
.studio-stage.studio-focus { border-radius: 0; background: var(--stage-bg); padding: 0; }
.studio-stage.studio-focus .studio-viewport { padding-top: 28px; }

/* Узкие экраны: телефон первым, без «рамки в рамке» на настоящем смартфоне */
@media (max-width: 639px) {
  .studio-viewport { padding: 12px 8px 16px; }
  .studio-device.is-mobile { width: 100%; border-radius: 22px; box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-1); margin: 0; }
  .phone-island, .phone-home { display: none; }
  .phone-status { height: 28px; padding: 0 16px; }
  .studio-key { min-height: 44px; padding: 6px 8px; gap: 4px; }
  .studio-key-mini { opacity: .7; min-width: 22px; width: 22px; height: 22px; }
  .studio-key-grip, .studio-key-go { display: none; }
  .dev-badge { height: 24px; font-size: 11.5px; }
  .studio-sub { display: none; }            /* телефон — первым, сразу под заголовком */
  .studio-head { margin-bottom: 10px; }
  .studio-stage { border-radius: var(--r-m); }
}
