/* VastuBase Hub · Боты — админка. Цвета, радиусы, шрифты — только переменные из tokens.css (общий контракт
   с аналитикой), светлая и тёмная тема — :root[data-theme]. Цвет — там, где он что-то значит:
   типы блоков (--t-*), каналы (--ch-*), состояния (--good/--warn/--bad). Остальное — нейтральные поверхности. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--blue) 28%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.dim { color: var(--faint); }
.ok { color: var(--good); } .warn { color: var(--warn); } .err { color: var(--bad); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- контролы */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); cursor: pointer; white-space: nowrap; user-select: none; text-decoration: none;
  transition-property: background-color, border-color, color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
}
@media (hover: hover) { .btn:hover { background: var(--hover); text-decoration: none; } }
.btn:not(:disabled):active { scale: 0.96; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
@media (hover: hover) { .btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); } }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: color-mix(in srgb, var(--bad) 6%, var(--card)); }
@media (hover: hover) { .btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, var(--card)); } }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
@media (hover: hover) { .btn.ghost:hover { background: var(--hover); color: var(--ink); } }
.btn.on { background: var(--active); color: var(--ink); border-color: var(--line-strong); }
.btn.chipf { color: var(--muted); } .btn.chipf.on { color: var(--ink); }
.btn .cnt { font-variant-numeric: tabular-nums; } .btn .cnt.err { color: var(--bad); } .btn .cnt.warn { color: var(--warn); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 30px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }

.input, select.input, textarea.input {
  width: 100%; height: 30px; padding: 0 9px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card); outline: none; min-width: 0; color: var(--ink);
}
.input::placeholder, textarea::placeholder { color: var(--faint); }
textarea.input { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.input:disabled { background: var(--surface); color: var(--muted); }
.input.bad { border-color: var(--bad); }
.input.code, textarea.code { font-family: var(--mono); font-size: 12px; }
select.input { padding-right: 24px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) calc(50% + 1px), calc(100% - 9px) calc(50% + 1px); background-size: 4px 4px; background-repeat: no-repeat; }
label.field { display: flex; flex-direction: column; gap: 5px; }
label.field > span, .label { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; padding: 3px 0; }
.check input { margin: 2px 0 0; accent-color: var(--blue); }
.check small { display: block; color: var(--muted); font-size: 12px; }
.col > .seg { align-self: flex-start; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 0 10px; height: 28px; cursor: pointer; white-space: nowrap; transition: background-color 150ms ease-out, color 150ms ease-out; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.seg button:disabled { cursor: default; }
.seg.full { display: flex; } .seg.full button { flex: 1; padding: 0 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, var(--line)); background: var(--good-soft); }
.badge.warn { color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-bg); }
.badge.err { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft); }
.kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--card); white-space: nowrap; }

/* ---------- каркас */
#app { height: 100%; display: flex; flex-direction: column; }
.top {
  height: 48px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--surface); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 14px; white-space: nowrap; line-height: 1; color: var(--ink); }
.brand .brand-sub { color: var(--muted); font-weight: 500; font-size: 13px; }
/* логотип VASTUBASE Hub: эмблема 22px терракотой, вордмарк 10.5px цветом текста, «Hub» 13.5px/650 терракотой (как в Hub) */
.wa-lockup { display: inline-flex; align-items: center; gap: 9px; line-height: 1; flex: none; }
.lk-emblem, .lk-word { display: block; flex: none; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; }
.lk-emblem { width: 22px; height: 22px; background: var(--brand); -webkit-mask-image: url(emblem.svg?v=3b41e89072); mask-image: url(emblem.svg?v=3b41e89072); }
.lk-word { width: 86.85px; height: 10.5px; background: currentColor; -webkit-mask-image: url(wordmark.svg?v=3b41e89072); mask-image: url(wordmark.svg?v=3b41e89072); } /* 1098.09 × 132.77 → высота 10.5 */
.lk-hub { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; color: var(--brand); margin-left: -1px; }
.nav { display: flex; gap: 2px; min-width: 0; }
.nav a { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; transition: background-color 150ms ease-out, color 150ms ease-out; }
@media (hover: hover) { .nav a:hover { color: var(--ink); background: var(--hover); text-decoration: none; } }
.nav a.on { color: var(--ink); background: var(--active); }
.nav a svg { width: 16px; height: 16px; }
.nav a .cnt { font-size: 11px; color: var(--bad); }
.top .user { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); min-width: 0; }
.top .user .who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; min-width: 0; }
.top .user .who small { color: var(--faint); font-size: 11px; }
/* встроенный режим: меню и шапка аналитики (WAShell, fixed + отступы <body>), разделы ботов — второй строкой */
.subnav { height: 42px; flex: none; display: flex; align-items: stretch; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav .crumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; padding-right: 4px; }
.subnav .crumb b { color: var(--ink); font-weight: 600; font-size: 13px; }
.subnav a { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; text-decoration: none; font-size: 13px; box-shadow: inset 0 -2px 0 transparent; transition: color 150ms ease-out, box-shadow 150ms ease-out; }
.subnav a svg { width: 15px; height: 15px; }
@media (hover: hover) { .subnav a:hover { color: var(--ink); text-decoration: none; } }
.subnav a.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.subnav .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.main { flex: 1; min-height: 0; position: relative; }
.page { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }
.page.pad { padding: 20px 24px 40px; }
.pagew { max-width: 1180px; margin: 0 auto; }
.bc-grid + .section { margin-top: 22px; }
h1 { font-size: 18px; font-weight: 650; margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 650; margin: 0 0 10px; }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
.tabbar { display: none; }
.role-note { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 14px 16px; }
.section + .section { margin-top: 22px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.loading { padding: 28px; color: var(--muted); text-align: center; }
.err-box { padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--bad) 7%, var(--card)); color: var(--bad); }

/* ---------- таблицы */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 500; font-size: 11px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.t th:first-child { border-top-left-radius: var(--radius); } table.t th:last-child { border-top-right-radius: var(--radius); }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
@media (hover: hover) { table.t tr.click:hover td { background: var(--hover); } }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- обзор */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; }
.bot-card { min-width: 0; }
.bot-card { padding: 14px 16px 6px; }
.bot-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-width: 0; }
.bot-head b { font-size: 15px; }
.bot-head .sub { color: var(--muted); font-size: 12px; }
.bot-head .badge { margin-left: auto; flex: none; }
.kv { display: flex; flex-direction: column; }
.kv-r { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 34px; padding: 7px 0; border-top: 1px solid var(--line); }
.kv-r > span { color: var(--muted); min-width: 0; }
.kv-r > b { flex: none; display: flex; align-items: baseline; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv b small { font-weight: 400; color: var(--muted); font-size: 12px; }
.kv b a { color: inherit; }
.kv b.err { color: var(--bad); } .kv b.warn { color: var(--warn); } .kv b.dim { color: var(--muted); font-weight: 400; }
.totals { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin-bottom: 14px; }
.totals > div { padding: 12px 16px; border-left: 1px solid var(--line); }
.totals > div:first-child { border-left: 0; }
.totals b { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.totals span { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--muted); }
.totals b.err { color: var(--bad); }

/* ---------- клиенты */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; }
.filters .search { flex: 1; min-width: 220px; }
.cl-name { font-weight: 550; }
.cl-sub { color: var(--muted); font-size: 12px; }
.client-page { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
.client-page .side { display: flex; flex-direction: column; gap: 12px; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12px; }
.props span { color: var(--muted); }
.props b { font-weight: 500; overflow-wrap: anywhere; }
.vars-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.vars-table td { padding: 3px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vars-table td:first-child { color: var(--muted); font-family: var(--mono); font-size: 12px; padding-right: 8px; width: 40%; word-break: break-all; }
.vars-table input { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 3px 6px; font-family: var(--mono); font-size: 12px; outline: none; }
.vars-table input:hover:not(:disabled) { border-color: var(--line-strong); }
.vars-table input:focus { border-color: var(--focus); background: var(--card); }
.vars-table input.changed { border-color: var(--warn); }
.vars-table tr.add input { border-color: var(--line); border-style: dashed; } /* строка новой переменной — видно, что это поле */
.vars-table td.x { width: 26px; text-align: right; }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 12px; overflow: auto; max-height: calc(100vh - 290px); min-height: 240px; overscroll-behavior: contain; }
.day { align-self: center; font-size: 11px; color: var(--muted); margin: 8px 0 2px; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12px; }
.task:first-child { border-top: 0; }

/* ---------- рассылки */
.bc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.step { padding: 14px 16px; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step h2 { display: flex; gap: 8px; align-items: center; }
.step h2 .n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ink); }
.job { padding: 12px 14px; border-top: 1px solid var(--line); }
.job:first-child { border-top: 0; }
.audience { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- журнал */
.ev-table { table-layout: fixed; }
.ev-table th.ev-when { width: 120px; } .ev-table th.ev-k { width: 128px; } .ev-table th.ev-who { width: 21%; } .ev-table th.ev-blk { width: 21%; }
.ev-table td.ev-who, .ev-table td.ev-blk { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-kind { font-size: 12px; white-space: nowrap; color: var(--muted); }
.ev-kind.err { color: var(--bad); } .ev-kind.warn { color: var(--warn); }
.ev-text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); max-height: 5.8em; overflow: hidden; }
.ev-text.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
a.plain { color: var(--ink); } a.plain.muted { color: var(--muted); }
@media (hover: hover) { a.plain:hover { color: var(--blue); text-decoration: none; } }

/* ---------- всплывашки и модалки */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 1000; pointer-events: none; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); max-width: 90vw; pointer-events: auto; border: 1px solid transparent; }
.toast.err { background: var(--bad); color: var(--card); }
.toast.ok { background: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: tin .16s ease-out; } }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.modal-bg { position: fixed; inset: 0; background: var(--overlay); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
.modal.wide { width: min(860px, 100%); }
.modal .mh { padding: 14px 16px 0; display: flex; align-items: center; gap: 8px; }
.modal .mh h2 { margin: 0; flex: 1; }
.modal .mb { padding: 14px 16px; overflow: auto; overscroll-behavior: contain; }
.modal .mf { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.pick-list { max-height: 360px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); overscroll-behavior: contain; }
.pick-item { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); }
.pick-item:last-child { border-bottom: 0; }
.pick-item.on { background: var(--active); }
@media (hover: hover) { .pick-item:hover { background: var(--hover); } .pick-item.on:hover { background: var(--active); } }
.pick-item .sub { color: var(--muted); font-size: 11px; }
.tdot { width: 8px; height: 8px; border-radius: 2px; flex: none; display: inline-block; }
.tc0 { background: var(--t-state); } .tc1 { background: var(--t-start); } .tc4 { background: var(--t-global); }
.tc5 { background: var(--t-primary); } .tc6 { background: var(--t-error); } .tc8 { background: var(--t-comment); }
.chdot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; background: var(--faint); }
.ch-TG, .ch-telegram { background: var(--ch-telegram); } .ch-VK, .ch-vk { background: var(--ch-vk); }
.ch-MAX, .ch-max { background: var(--ch-max); } .ch-IG, .ch-instagram { background: var(--ch-instagram); }

/* ---------- вход */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login .brand { margin: 0 0 8px; }
.login p { margin: 0; color: var(--muted); }
.login .alt { border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }

/* ---------- превью Telegram — нейтральная подложка с оттенком канала, читается в обеих темах */
.tg { background: color-mix(in srgb, var(--ch-telegram) 9%, var(--bg)); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tg-bubble { background: var(--card); color: var(--ink); border-radius: 12px 12px 12px 4px; padding: 7px 10px 8px; max-width: 100%; font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 1px 0 var(--line); }
.tg-bubble a { color: var(--ch-telegram); }
.tg-bubble code { font-family: var(--mono); font-size: 12px; color: var(--warn); }
.tg-bubble pre { font-family: var(--mono); font-size: 12px; background: var(--surface); padding: 6px 8px; border-radius: var(--radius-sm); margin: 4px 0; white-space: pre-wrap; }
.tg-bubble blockquote { margin: 3px 0; padding: 2px 8px; border-left: 3px solid var(--ch-telegram); background: color-mix(in srgb, var(--ch-telegram) 10%, var(--card)); border-radius: 3px; }
.tg-bubble .spoiler { background: var(--line-strong); color: transparent; border-radius: 3px; }
.tg-bubble .spoiler:hover { color: inherit; background: var(--hover); }
.tg-bubble .var { font-family: var(--mono); font-size: 12px; color: var(--warn-ink); background: var(--warn-bg); padding: 0 3px; border-radius: 3px; }
.tg-att { font-size: 12px; color: var(--ch-telegram); padding: 5px 8px; background: var(--card); border-radius: 8px; margin-bottom: 4px; overflow-wrap: anywhere; }
.tg-kb { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.tg-kb .r { display: flex; gap: 3px; }
.tg-kb .b { flex: 1; text-align: center; background: color-mix(in srgb, var(--ch-telegram) 16%, var(--card)); color: var(--ink); border-radius: var(--radius-sm); padding: 6px 6px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-decoration: none; }
.tg-kb .b.url::after { content: " ↗"; color: var(--muted); }
.tg-kb.reply .b { background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
button.b { cursor: pointer; }
@media (hover: hover) { button.b:hover { background: color-mix(in srgb, var(--ch-telegram) 26%, var(--card)); } }
.tg-err { font-size: 11px; color: var(--bad); margin-top: 4px; }

/* =================================================================== конструктор */
.builder { position: absolute; inset: 0; display: flex; flex-direction: column; }
.btool { height: 44px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--surface); z-index: 5; }
.btool > svg { width: 16px; height: 16px; flex: none; }
.btool .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.btool .zoom { width: 44px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; cursor: pointer; }
.btool .status { color: var(--muted); font-size: 12px; white-space: nowrap; border-left: 1px solid var(--line); padding-left: 10px; margin-left: 4px; line-height: 20px; }
.btool.banner { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); color: var(--warn-ink); }
.btool.banner.info { background: var(--surface); color: var(--muted); }
.search-box { position: relative; width: 300px; display: flex; align-items: center; }
.search-box .input { padding-left: 28px; }
.search-box.has-q .input { padding-right: 116px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box > svg { position: absolute; left: 8px; top: calc(50% - 8px); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search-nav { position: absolute; right: 3px; top: 3px; height: 24px; display: flex; align-items: center; gap: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.search-nav .btn { height: 24px; width: 24px; }
.search-nav span { padding: 0 4px; white-space: nowrap; }
.search-res { position: absolute; top: 34px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); max-height: 60vh; overflow: auto; box-shadow: var(--shadow-pop); z-index: 30; overscroll-behavior: contain; }
.search-res .pick-item { font-size: 12px; }
.search-res .hint-row { padding: 6px 10px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface); }
mark { background: color-mix(in srgb, var(--accent) 45%, transparent); color: inherit; border-radius: 2px; }
.bbody { flex: 1; min-height: 0; display: flex; position: relative; }
.viewport { flex: 1; min-width: 0; position: relative; overflow: hidden; background: var(--bg); cursor: default; touch-action: none; outline: none; container-type: inline-size;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--ink) 13%, transparent) 1px, transparent 1px); background-size: 20px 20px; }
.viewport.panning { cursor: grabbing; }
.viewport.space { cursor: grab; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world.moving { will-change: transform; }
.edges { position: absolute; left: 0; top: 0; overflow: visible; width: 1px; height: 1px; pointer-events: none; }
.edges path.e { fill: none; stroke: color-mix(in srgb, var(--ink) 32%, var(--bg)); stroke-width: 1.4; pointer-events: none; }
.edges path.e.timer { stroke-dasharray: 5 4; }
.edges path.e.cal { stroke-dasharray: 2 3; }
.edges path.hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.edges path.e.hl { stroke: color-mix(in srgb, var(--ink) 62%, var(--bg)); stroke-width: 1.8; }
.edges path.e.sel { stroke: var(--focus); stroke-width: 2.2; }
.edges path.e.bad { stroke: var(--bad); }
.edges path.e.path { stroke: var(--accent); stroke-width: 2.6; }
.edges path.e.faded { opacity: .22; }
.edges path.tmp { fill: none; stroke: var(--focus); stroke-width: 1.8; stroke-dasharray: 6 4; }
.edges marker path { fill: color-mix(in srgb, var(--ink) 32%, var(--bg)); }
.edges marker#ahh path { fill: color-mix(in srgb, var(--ink) 62%, var(--bg)); }
.edges marker#ahs path { fill: var(--focus); }
.edges marker#ahb path { fill: var(--bad); }
.edges marker#ahp path { fill: var(--accent); }
.labels { position: absolute; left: 0; top: 0; }
.elabel { position: absolute; transform: translate(-50%, -50%); font-size: 10.5px; line-height: 15px; height: 17px; padding: 0 6px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.elabel.timer { color: var(--warn); }
.elabel.cal { color: var(--blue); }
.elabel.any { color: var(--faint); }
.elabel.sel { border-color: var(--focus); color: var(--ink); z-index: 2; }
.elabel.hl { border-color: var(--line-strong); color: var(--ink); z-index: 1; }
.elabel.bad { border-color: var(--bad); }
.elabel.path { border-color: var(--accent); color: var(--ink); z-index: 1; }
.elabel.faded { opacity: .3; }
.nodes { position: absolute; left: 0; top: 0; }
.node {
  position: absolute; width: 180px; height: 104px; border-radius: 8px; background: var(--card); border: 1px solid var(--line);
  overflow: hidden; cursor: pointer; user-select: none; display: flex; flex-direction: column;
  box-shadow: inset 3px 0 0 var(--tc, var(--t-state));
  transition: opacity 150ms ease-out;
}
@media (hover: hover) { .node:hover { border-color: var(--line-strong); } }
.node.sel { border-color: var(--focus); box-shadow: inset 3px 0 0 var(--tc), 0 0 0 1px var(--focus), 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); z-index: 3; }
.node.t0 { --tc: var(--t-state); } .node.t1 { --tc: var(--t-start); } .node.t4 { --tc: var(--t-global); }
.node.t5 { --tc: var(--t-primary); } .node.t6 { --tc: var(--t-error); }
.node.t8 { --tc: var(--t-comment); background: var(--surface); border-style: dashed; }

.node .nh { display: flex; align-items: center; gap: 6px; padding: 6px 8px 2px 11px; font-weight: 600; font-size: 12px; color: var(--ink); }
.node .nh .nt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .nh .ty { font-size: 10.5px; color: var(--tc); font-weight: 500; flex: none; }
.node .nc { margin: 1px 8px 0 11px; font: 10.5px/14px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .nb { margin: 2px 8px 0 11px; font-size: 11px; line-height: 14px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; flex: 1; min-height: 0; word-break: break-word; }
.node.t8 .nb { -webkit-line-clamp: 5; }
.node .nf { display: flex; gap: 8px; padding: 0 8px 5px 11px; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.node .nf .e { color: var(--bad); } .node .nf .w { color: var(--warn); }
.node .port { position: absolute; right: -1px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--line-strong); border: 2px solid var(--card); cursor: crosshair; opacity: 0; transition: opacity 100ms ease-out; }
.node.sel .port { opacity: 1; }
@media (hover: hover) { .node:hover .port { opacity: 1; } .node .port:hover { background: var(--focus); } }
.viewport.ro .node .port { display: none; }
.node.linkable { border-color: var(--focus); }
.node.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: inset 3px 0 0 var(--tc), 0 0 0 4px color-mix(in srgb, var(--focus) 55%, transparent); } 100% { box-shadow: inset 3px 0 0 var(--tc), 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .node.flash { animation: none; } }
.node.simcur { border-color: var(--good); box-shadow: inset 3px 0 0 var(--tc), 0 0 0 1px var(--good); }
.node .mark { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; }
.node .mark.e { background: var(--bad); } .node .mark.w { background: var(--warn); }
/* поиск и путь клиента: совпадения яркие, остальное приглушено */
.world.filtering .node:not(.hit):not(.onpath) { opacity: .28; }
.world.filtering .elabel:not(.path) { opacity: .3; }
.node.hit { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--tc), 0 0 0 1px var(--accent); }
.node.hit.cur { box-shadow: inset 3px 0 0 var(--tc), 0 0 0 2px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); z-index: 2; }
.node.onpath { border-color: var(--accent); }
.node .step { position: absolute; top: -1px; right: -1px; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 0 8px 0 7px; background: var(--accent); color: var(--accent-ink); font: 650 10.5px/18px var(--font); text-align: center; font-variant-numeric: tabular-nums; }
.node.pathnow .step { background: var(--ink); color: var(--bg); }
.marquee { position: absolute; border: 1px solid var(--focus); background: color-mix(in srgb, var(--focus) 8%, transparent); pointer-events: none; }
/* уровни детализации по масштабу: ближе — всё, дальше — крупные названия, совсем далеко — цветные плашки */
.world.lod2 .node .nb, .world.lod2 .node .nf, .world.lod2 .node .ty { display: none; }
.world.lod2 .node .nh { font-size: 18px; line-height: 1.2; padding: 9px 10px 2px 13px; align-items: flex-start; }
.world.lod2 .node .nh .nt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.world.lod2 .node .nc { font-size: 13px; line-height: 17px; margin-left: 13px; }
.world.lod1 .node .nb, .world.lod1 .node .nf, .world.lod1 .node .nc, .world.lod1 .node .ty,
.world.lod0 .node .nb, .world.lod0 .node .nf, .world.lod0 .node .nc, .world.lod0 .node .ty { display: none; }
.world.lod1 .node .nh { font-size: 28px; line-height: 1.1; padding: 10px 10px 0 15px; white-space: normal; align-items: flex-start; }
.world.lod1 .node .nh .nt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.world.lod0 .node .nh { font-size: 44px; line-height: 1.08; padding: 8px 10px 0 16px; white-space: normal; align-items: flex-start; }
.world.lod0 .node .nh .nt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.world.lod1 .elabel, .world.lod0 .elabel, .world.dots .elabel { display: none; }
.world.lod1 .node, .world.lod0 .node { box-shadow: inset 7px 0 0 var(--tc); }
.world.lod0 .node.t8, .world.dots .node.t8 { opacity: .55; }
.world.dots .node { background: color-mix(in srgb, var(--tc) 30%, var(--card)); border-color: color-mix(in srgb, var(--tc) 55%, var(--card)); box-shadow: none; }
.world.dots .node > * { display: none; }
.world.dots .node.sel { background: var(--focus); }
.world.lod1 .node .step, .world.lod0 .node .step, .world.dots .node .step { font-size: 30px; line-height: 40px; height: 40px; min-width: 44px; border-radius: 0 8px 0 12px; display: block; }
.world.lod1 .edges path.e { stroke-width: 3; } .world.lod0 .edges path.e { stroke-width: 4.5; } .world.dots .edges path.e { stroke-width: 7; }
.world.lod1 .edges path.e.path, .world.lod0 .edges path.e.path, .world.dots .edges path.e.path { stroke-width: 9; }
.world.lod1 .node.sel, .world.lod0 .node.sel { box-shadow: inset 7px 0 0 var(--tc), 0 0 0 4px var(--focus); }
.world.lod1 .node.hit, .world.lod0 .node.hit, .world.dots .node.hit { box-shadow: 0 0 0 6px var(--accent); }
.landmarks { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.landmark { position: absolute; left: 0; top: 0; font: 650 12px/18px var(--font); letter-spacing: .02em; color: var(--ink); background: color-mix(in srgb, var(--bg) 82%, transparent); border: 1px solid var(--line); padding: 1px 8px; border-radius: 6px; white-space: nowrap; box-shadow: var(--shadow); }
@media (min-width: 761px) { @container (max-width: 720px) { .minimap { display: none; } } }
.minimap { position: absolute; right: 12px; bottom: 12px; width: 200px; height: 140px; background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; z-index: 4; touch-action: none; box-shadow: var(--shadow); }
.vp-hint { position: absolute; left: 12px; bottom: 12px; color: var(--muted); font-size: 11px; z-index: 4; pointer-events: none; display: flex; gap: 6px; align-items: center; }
.zoombox { position: absolute; right: 12px; bottom: 160px; display: flex; flex-direction: column; gap: 4px; z-index: 4; }
.zoombox .btn { box-shadow: var(--shadow); }
/* быстрые действия над выбранным блоком */
.qa { position: absolute; z-index: 6; display: flex; gap: 2px; padding: 3px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 9px; box-shadow: var(--shadow); transform: translate(-50%, -100%); white-space: nowrap; }
.qa .btn { height: 28px; border: 0; background: transparent; color: var(--muted); padding: 0 8px; font-size: 12px; }
.qa .btn.icon { width: 28px; padding: 0; }
@media (hover: hover) { .qa .btn:hover { background: var(--hover); color: var(--ink); } }
.qa .btn.danger, .btn.ghost.danger { color: var(--muted); }
@media (hover: hover) { .qa .btn.danger:hover, .btn.ghost.danger:hover { color: var(--bad); background: var(--bad-soft); } }
.qa .sep { width: 1px; background: var(--line); margin: 4px 2px; }
.qa.hidden-soft { opacity: 0; pointer-events: none; }
/* плашки поверх холста: путь клиента, черновик, пустая схема */
.overlay-top { position: absolute; left: 12px; right: 12px; top: 10px; z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.chipbar { pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: min(720px, 100%); padding: 5px 6px 5px 12px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
.chipbar .lead { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.chipbar b { font-weight: 600; }
.chipbar .btn.sm { height: 26px; }
.chipbar.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.chipbar.warn .lead { background: var(--warn); }
.canvas-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; pointer-events: none; }
.canvas-empty > div { pointer-events: auto; text-align: center; max-width: 340px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.canvas-empty b { color: var(--ink); font-size: 15px; }
.canvas-empty svg { width: 32px; height: 32px; color: var(--line-strong); }
/* инспектор */
.panel { width: 400px; flex: none; border-left: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.panel .ph { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; min-height: 48px; }
.panel .ph .ttl { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .ph .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.panel .pb { flex: 1; overflow: auto; padding: 4px 14px 40px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.panel .grip { display: none; }
.pactions { display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.psec { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; }
.psec + .psec { border-top: 1px solid var(--line); }
.psec > .hd { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); font-weight: 600; min-height: 22px; }
.psec > .hd .note { font-weight: 400; color: var(--muted); font-size: 12px; }
.psec > .hd .cnt { font-weight: 500; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.psec.fold > .hd { margin: -4px -6px; }
.psec.fold > .hd .tg { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; padding: 4px 6px; border-radius: var(--radius-sm); border: 0; background: transparent; text-align: left; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); transition: background-color 150ms ease-out; }
@media (hover: hover) { .psec.fold > .hd .tg:hover { background: var(--hover); } }
.psec.fold > .hd .tg svg { width: 14px; height: 14px; color: var(--muted); flex: none; transition: rotate 150ms ease-out; }
.psec.fold.closed > .hd .tg svg { rotate: -90deg; }
.psec.fold > .hd .note { margin-right: 6px; }
.psec.fold.closed > :not(.hd) { display: none; }
.psec.fold.closed { padding-bottom: 12px; }
.hint { position: relative; display: inline-flex; width: 15px; height: 15px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: none; color: var(--muted); font: 600 10px/13px var(--font); justify-content: center; cursor: help; flex: none; }
.hint::after { content: ""; position: absolute; inset: -12px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.45; }
.help code { font-family: var(--mono); font-size: 11px; color: var(--ink); background: var(--surface); padding: 0 3px; border-radius: 3px; }
.typebar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.typebar button { min-height: 30px; border: 1px solid var(--line-strong); background: var(--card); border-radius: var(--radius-sm); cursor: pointer; display: flex; gap: 6px; align-items: center; padding: 4px 7px; color: var(--muted); font-size: 12px; text-align: left; line-height: 1.2; transition: background-color 150ms ease-out, border-color 150ms ease-out; }
.typebar button.on { color: var(--ink); border-color: var(--ink); background: var(--active); }
.typebar button:disabled { cursor: default; }
@media (hover: hover) { .typebar button:not(:disabled):not(.on):hover { background: var(--hover); } }
.code-wrap { position: relative; display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); overflow: hidden; }
.code-wrap:focus-within { border-color: var(--focus); }
.code-wrap .gut { flex: none; width: 30px; padding: 7px 0; text-align: right; font: 12px/18px var(--mono); color: var(--faint); background: var(--surface); user-select: none; overflow: hidden; }
.code-wrap .gut div { padding-right: 6px; }
.code-wrap .gut div.e { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); font-weight: 650; }
.code-wrap .gut div.t { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.code-wrap textarea { flex: 1; border: 0; background: transparent; outline: none; padding: 7px 8px; font: 12px/18px var(--mono); resize: vertical; min-height: 62px; white-space: pre; overflow-x: auto; tab-size: 2; color: var(--ink); }
.cerrs { font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.cerrs .e { color: var(--bad); } .cerrs .t { color: var(--muted); }
.btn-row { display: flex; gap: 4px; align-items: center; }
.btn-ed { display: flex; flex-direction: column; gap: 6px; }
.btn-line { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.btn-line .lh { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.btn-item { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; }
.btn-item .input { height: 27px; font-size: 12px; }
.arrow-list { display: flex; flex-direction: column; }
.arrow-list .ai { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; }
@media (hover: hover) { .arrow-list .ai:hover { background: var(--hover); } }
.arrow-list .ai .lb { color: var(--ink); max-width: 46%; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.arrow-list .ai .to { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrow-list .ai .kind { flex: none; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.issues { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; overscroll-behavior: contain; }
.issue { display: flex; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; align-items: baseline; }
@media (hover: hover) { .issue:hover { background: var(--hover); } }
.issue i { width: 7px; height: 7px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.issue.e i { background: var(--bad); } .issue.w i { background: var(--warn); }
.ver { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.ver:last-child { border-bottom: 0; }
.ver.cur { background: var(--surface); }
.stat-list { display: flex; flex-direction: column; gap: 5px; }
.stat-list .row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; }
.keys h3 { margin: 0 0 8px; }
.keys .k { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.keys .k:last-child { border-bottom: 0; }
.keys .k span:first-child { color: var(--muted); }
.keys .k span:last-child { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- тест-чат: подложка с оттенком Telegram, читается в обеих темах */
.sim { width: 380px; flex: none; border-left: 1px solid var(--line); background: color-mix(in srgb, var(--ch-telegram) 7%, var(--bg)); display: flex; flex-direction: column; min-height: 0; }
.sim .sh { padding: 8px 10px; display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); background: var(--card); }
.sim .sh b { flex: 1; font-size: 13px; }
.sim .log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.sim .me { align-self: flex-end; background: color-mix(in srgb, var(--ch-telegram) 24%, var(--card)); color: var(--ink); border-radius: 12px 12px 4px 12px; padding: 6px 10px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.sim .bot { align-self: flex-start; max-width: 92%; display: flex; flex-direction: column; gap: 0; }
.sim .bot .bid { font-size: 11px; color: var(--muted); margin: 0 0 2px 2px; cursor: pointer; }
@media (hover: hover) { .sim .bot .bid:hover { color: var(--blue); } }
.sim .note { align-self: center; font-size: 11px; color: var(--muted); background: var(--card); padding: 2px 9px; border-radius: 9px; text-align: center; max-width: 95%; overflow-wrap: anywhere; }
.sim .note.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--card)); }
.sim .note.fx { color: var(--warn-ink); background: var(--warn-bg); }
.sim .ctrl { border-top: 1px solid var(--line); background: var(--card); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.sim .reply-kb { display: flex; flex-direction: column; gap: 3px; }
.sim .state { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; max-height: 30vh; overflow: auto; }
.sim .state pre { margin: 0; font: 11px var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.sim .sh > svg { width: 16px; height: 16px; color: var(--good); flex: none; }
.sim .sh select.input { min-width: 96px; }

.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font: inherit; text-align: left; }
@media (hover: hover) { .linkbtn:hover { text-decoration: underline; } }

/* =================================================================== диалоги */
.dlg { position: absolute; inset: 0; display: grid; grid-template-columns: 360px minmax(0, 1fr); }
.dl-list { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--card); }
.dl-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; }
.dl-head h1 { margin: 0; flex: 1; font-size: 16px; }
.live { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.live.ok i { background: var(--good); }
@media (prefers-reduced-motion: no-preference) { .live.ok i { animation: pulse 2.5s ease-in-out infinite; } }
.live.bad i { background: var(--warn); }
.live.bad { color: var(--warn); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.dl-filters { display: flex; gap: 6px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.dl-filters .input[type=search] { flex: 1; }
.dl-filters select.input { flex: none; min-width: 112px; }
.dl-items { flex: 1; overflow: auto; overscroll-behavior: contain; }
.di { display: block; padding: 9px 14px 10px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; position: relative; transition: background-color 150ms ease-out; }
@media (hover: hover) { .di:hover { background: var(--hover); text-decoration: none; } }
.di.on { background: var(--active); }
.di.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.di-top { display: flex; align-items: center; gap: 6px; }
.di-top b { font-weight: 600; flex: 1; min-width: 0; }
.di-time { font-size: 11px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.quiet-tag { flex: none; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; line-height: 16px; white-space: nowrap; font-weight: 400; }
.di-alert { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); flex: none; }
.di-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.di-last { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 3px; min-width: 0; }
.di-last .ellipsis { min-width: 0; flex: 1; }
.di.new .di-last { color: var(--ink); }
.di-new { flex: none; font-size: 11px; font-weight: 600; color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.dl-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.dl-empty { margin: auto; color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; }
.dl-empty svg { width: 32px; height: 32px; color: var(--line-strong); }
.dl-chead { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); min-height: 54px; }
.dl-back { display: none; }
.dl-sum { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); font-size: 12px; max-height: 92px; overflow: auto; }
.chip { display: inline-flex; gap: 2px; align-items: baseline; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.mono { font-size: 11px; cursor: copy; }
.dl-logwrap { flex: 1; min-height: 0; position: relative; }
.dl-log { position: absolute; inset: 0; overflow: auto; padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.dl-more { align-self: center; margin-bottom: 6px; }
.dl-pill { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--ink); color: var(--bg); border: 0; border-radius: 14px; padding: 5px 12px; font-weight: 600; font-size: 12px; cursor: pointer; box-shadow: var(--shadow); }
.cm { display: flex; flex-direction: column; max-width: min(560px, 82%); gap: 3px; }
.cm.in { align-self: flex-start; }
.cm.out { align-self: flex-end; align-items: flex-end; }
.cm .cl { font-size: 11px; color: var(--muted); padding: 0 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm.cont { margin-top: -3px; }
.cm .cl a { color: var(--muted); }
.cb { padding: 7px 10px 6px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.42; max-width: 100%; color: var(--ink); }
.cm.in .cb { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cm.out .cb { background: var(--blue-soft); border-bottom-right-radius: 4px; }
.cm.out.manual .cb { background: color-mix(in srgb, var(--t-primary) 15%, var(--card)); }
.cm.out .cb.media { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.cb a { color: var(--blue); }
.cb code { font-family: var(--mono); font-size: 12px; color: var(--warn); }
.cb pre { font-family: var(--mono); font-size: 12px; background: var(--surface); padding: 6px 8px; border-radius: var(--radius-sm); margin: 4px 0; white-space: pre-wrap; }
.cb blockquote { margin: 3px 0; padding: 2px 8px; border-left: 3px solid var(--ch-telegram); background: color-mix(in srgb, var(--ch-telegram) 8%, transparent); }
.cb .spoiler { background: var(--line-strong); color: transparent; border-radius: 3px; }
.cb .var { font-family: var(--mono); font-size: 12px; color: var(--warn-ink); }
.ct { float: right; margin: 4px 0 -2px 10px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.cimg { display: block; border-radius: 10px; overflow: hidden; max-width: 280px; position: relative; }
.cimg img { display: block; width: 100%; max-height: 320px; object-fit: cover; background: var(--surface); min-height: 60px; outline: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); outline-offset: -1px; border-radius: 10px; }
.catt { display: block; padding: 7px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--blue); font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catt-k { color: var(--muted); } .catt-k::after { content: "·"; margin: 0 6px; }
.chips { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; max-width: 100%; }
.chips-r { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.chipb { display: inline-block; padding: 4px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line-strong); color: var(--ink); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
@media (hover: hover) { a.chipb:hover { text-decoration: none; border-color: var(--blue); } }
.chipb.url::after { content: " ↗"; color: var(--muted); }
.chips.reply .chipb { background: transparent; border-style: dashed; color: var(--muted); border-radius: var(--radius-sm); }
.csys { align-self: center; font-size: 12px; line-height: 1.45; color: var(--muted); padding: 3px 10px; border-radius: var(--radius-sm); background: var(--surface); max-width: min(640px, 88%); text-align: center; overflow-wrap: anywhere; text-wrap: balance; }
.csys.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--card)); }
.csys a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); }
.dl-compose { display: flex; gap: 6px; align-items: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--card); }
.dl-compose textarea { flex: 1; resize: none; min-height: 30px; max-height: 160px; padding: 5px 9px; line-height: 18px; }
.dl-compose select { flex: none; }

/* =================================================================== телефон */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .top { padding: 0 8px 0 12px; height: 46px; }
  .top .nav { display: none; }
  .top .user .who { display: none; }
  .desk-only { display: none; }
  .brand { margin-right: 0; }
  .subnav { display: none; }
  .tabbar { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; color: var(--muted); font-size: 11px; text-decoration: none; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on svg { color: var(--ink); }
  .page.pad { padding: 14px 12px 28px; }
  h1 { font-size: 17px; margin-bottom: 12px; }
  .btn { height: 38px; }
  .btn.sm { height: 34px; }
  .btn.icon { width: 38px; } .btn.sm.icon { width: 34px; }
  .dl-compose textarea { min-height: 38px; padding: 8px 9px; line-height: 20px; }
  .chat { max-height: none; overflow: visible; } /* карточка клиента: одна прокрутка страницы, без вложенной */
  .edges path.hit { stroke-width: calc(32px / var(--k, 1)); } /* по стрелке можно попасть пальцем на любом масштабе */
  .input, select.input { height: 38px; font-size: 16px; }
  textarea.input, .code-wrap textarea { font-size: 16px; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals > div:nth-child(odd) { border-left: 0; }
  .totals > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .totals > div { padding: 10px 14px; }
  .totals b { font-size: 19px; }
  .totals span { font-size: 12px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .btool > .btn { width: 38px; padding: 0; } /* на телефоне у кнопок тулбара только иконки — квадратные */
  .client-page { grid-template-columns: 1fr; }
  .bc-grid { grid-template-columns: 1fr; }
  .filters .search { min-width: 100%; }
  .varrow > .input:first-child { flex-basis: 100%; }
  .varrow { flex-wrap: wrap; }
  .varrow > select.input { flex: 0 0 104px; width: 104px; }
  .varrow > .input:last-child { flex: 1 1 0; width: auto; min-width: 0; }
  .filters .input { flex: 1; }
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
  table.t.cards td { border: 0; padding: 1px 0; text-align: left !important; width: auto; font-size: 13px; }
  table.t.cards td:first-child { flex-basis: 100%; }
  table.t.cards td:last-child:not([data-l]) { flex-basis: 100%; }
  table.t.cards td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: 11px; }
  .chat { max-height: 65vh; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: 14px 14px 0 0; max-height: 88vh; }
  .keys { grid-template-columns: 1fr; }
  /* конструктор на телефоне: просмотр, поиск, правка в шторке */
  .btool { gap: 4px; padding: 0 8px; }
  .btool .desk { display: none !important; }
  .search-box { width: auto; flex: 1; }
  .search-box.has-q .input { padding-right: 116px; }
  .search-res { position: fixed; top: 96px; left: 8px; right: 8px; }
  .panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 62%; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 14px 14px 0 0; z-index: 10; box-shadow: var(--shadow); }
  .panel.full { height: 100%; border-radius: 0; }
  .panel.dragging { transition: none !important; }
  .builder.nosel .panel { display: none; }
  .panel .grip { display: block; height: 22px; margin: 0 0 -8px; flex: none; position: relative; touch-action: none; cursor: grab; }
  .panel .grip::before { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-strong); }
  .panel .ph { min-height: 44px; padding: 6px 12px; touch-action: none; }
  .panel .pb { padding: 0 12px 40px; }
  .sim { position: absolute; inset: 0; width: auto; z-index: 11; }
  .minimap { width: 120px; height: 84px; right: 8px; bottom: 8px; }
  .zoombox { display: none; }
  .vp-hint { display: none; }
  .qa { display: none; }
  .node .port { display: none; }
  .typebar { grid-template-columns: repeat(2, 1fr); }
  .overlay-top { left: 8px; right: 8px; top: 8px; }
  .chipbar { font-size: 12px; flex-wrap: wrap; padding: 5px 6px 5px 10px; }
  .dlg { grid-template-columns: minmax(0, 1fr); }
  .dlg.open .dl-list { display: none; }
  .dlg:not(.open) .dl-chat { display: none; }
  .dl-back { display: inline-flex; }
  body.chat-full .tabbar { display: none; }
  .dl-log { padding: 10px 10px 14px; }
  .cm { max-width: 88%; }
  .dl-sum { max-height: 64px; flex-wrap: nowrap; overflow-x: auto; }
  .dl-compose { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .dl-compose select { display: none; }
  .dl-chead { padding: 6px 8px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  .panel { transition: height 280ms cubic-bezier(0.2, 0, 0, 1); }
}
@media (hover: none) { .node .port { display: none; } }
@media (prefers-reduced-motion: reduce) { .btn:not(:disabled):active { scale: 1; } }
@media (prefers-reduced-motion: reduce) { .psec.fold > .hd .tg svg { transition: none; } }
