:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #d8e0ea;
  --blue: #2563eb;
  --green: #10b981;
  --pink: #f43f5e;
  --amber: #f59e0b;
  --violet: #5b45e8;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: #0f172a;
  color: white;
  padding: 20px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #24c6dc, #6d4cff); font-weight: 800;
}
.brand small { display: block; color: #aab5c8; margin-top: 2px; }
nav { display: grid; gap: 8px; }
button, input, textarea, select { font: inherit; }
.nav-btn {
  border: 0; text-align: left; padding: 12px 14px; border-radius: 8px;
  color: #cbd5e1; background: transparent; cursor: pointer;
}
.nav-btn.active, .nav-btn:hover { background: #1e293b; color: white; }

.app { min-width: 0; height: 100vh; overflow: auto; }
.topbar {
  height: 76px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; padding: 0 28px;
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px);
}
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0; }
p { color: var(--muted); margin: 0; line-height: 1.45; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.primary { background: var(--blue); color: white; border-color: var(--blue); }
button, select, input, textarea {
  border: 1px solid var(--line); border-radius: 8px; background: white; padding: 10px 12px;
}
button { cursor: pointer; }
.view { display: none; padding: 24px 28px; }
.view.active { display: block; }
#builderView.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 76px);
  overflow: hidden;
  padding: 12px;
}
body.builder-mode .topbar {
  display: none;
}
body.builder-mode #builderView.view.active {
  height: 100vh;
  padding: 8px;
}
body.tables-mode .topbar {
  display: none;
}
body.tables-mode #crmView.view.active {
  height: 100vh;
  padding: 10px 12px;
  overflow: hidden;
}
.ecosystem-stage {
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(360px, .86fr) minmax(520px, 1.14fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 18px;
  background:
    linear-gradient(120deg, rgba(255,255,255,.96), rgba(240,249,255,.96) 48%, rgba(236,253,245,.94)),
    url("data:image/svg+xml,%3Csvg width='1400' height='520' viewBox='0 0 1400 520' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23cbd5e1' stroke-width='1'%3E%3Cpath d='M0 420 C260 310 340 490 620 360 S1030 180 1400 300'/%3E%3Cpath d='M0 250 C240 150 410 290 660 210 S1050 80 1400 170'/%3E%3Cpath d='M0 110 C210 70 380 140 560 110 S1000 20 1400 80'/%3E%3C/g%3E%3C/svg%3E");
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stage-copy {
  padding: 38px;
  display: grid;
  align-content: center;
  gap: 18px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
}
.stage-copy h2 {
  font-size: 42px;
  line-height: 1.04;
  max-width: 620px;
}
.stage-copy p {
  max-width: 610px;
  font-size: 16px;
  color: #475569;
}
.stage-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ecosystem-map {
  position: relative;
  min-height: 420px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.65)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(148,163,184,.18) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(148,163,184,.18) 32px);
}
.ecosystem-map::before,
.ecosystem-map::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(37, 99, 235, .22);
  border-radius: 50%;
}
.ecosystem-map::before { width: 520px; height: 270px; }
.ecosystem-map::after { width: 360px; height: 190px; border-color: rgba(16, 185, 129, .28); }
.core-node,
.orbit {
  position: absolute;
  border: 1px solid rgba(148, 163, 184, .58);
  box-shadow: 0 14px 35px rgba(15,23,42,.12);
  background: rgba(255,255,255,.94);
}
.core-node {
  left: 50%;
  top: 50%;
  width: 190px;
  height: 110px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 2;
}
.core-node strong { font-size: 26px; color: #1d4ed8; }
.core-node span,
.orbit small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.orbit {
  width: 165px;
  min-height: 78px;
  border-radius: 8px;
  padding: 14px;
  z-index: 1;
}
.orbit b { display: block; font-size: 15px; }
.orbit-telegram { left: 9%; top: 15%; border-top: 4px solid var(--blue); }
.orbit-instagram { right: 12%; top: 13%; border-top: 4px solid var(--pink); }
.orbit-crm { left: 7%; bottom: 17%; border-top: 4px solid var(--amber); }
.orbit-lms { right: 9%; bottom: 16%; border-top: 4px solid var(--green); }
.orbit-mail { left: 39%; top: 6%; border-top: 4px solid #0891b2; }
.orbit-analytics { left: 41%; bottom: 7%; border-top: 4px solid var(--violet); }
.journey-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.journey-step {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 92px;
}

.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}
.dashboard-toolbar h2 {
  font-size: 24px;
}
.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.segmented button,
.flow-tabs button {
  padding: 8px 12px;
  background: white;
}
.segmented button.active,
.flow-tabs button.active {
  background: var(--violet);
  border-color: var(--violet);
  color: white;
}
.flow-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.stress-card {
  min-height: 220px;
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  gap: 20px;
}
.stress-donut {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto;
  box-shadow: inset 0 0 0 22px rgba(255,255,255,.82), 0 16px 30px rgba(15,23,42,.12);
}
.stress-donut span {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  align-content: center;
  box-shadow: 0 8px 20px rgba(15,23,42,.1);
}
.stress-donut b { font-size: 28px; }
.stress-donut small,
table small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.stress-legend {
  display: grid;
  gap: 14px;
}
.stress-legend div {
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 10px;
  align-items: center;
}
.stress-legend i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.stress-legend i.green { background: var(--green); }
.stress-legend i.amber { background: var(--amber); }
.stress-legend i.pink { background: var(--pink); }
.stress-legend span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}
.journey-step::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 42px;
  width: 14px;
  height: 14px;
  border-top: 2px solid #94a3b8;
  border-right: 2px solid #94a3b8;
  transform: rotate(45deg);
  background: var(--bg);
  z-index: 1;
}
.journey-step:last-child::after { display: none; }
.journey-step b { display: block; font-size: 14px; margin-bottom: 8px; }
.journey-step span { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.two { grid-template-columns: minmax(0, 1fr) 420px; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px;
  box-shadow: 0 8px 30px rgba(15,23,42,.05);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pill { border-radius: 999px; padding: 5px 10px; background: #edf2ff; color: #3b44a5; font-size: 12px; }
.pill.ok { background: #dcfce7; color: #047857; }
.pill.warn { background: #fef3c7; color: #92400e; }

.stage-bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 110px 1fr 58px; gap: 10px; align-items: center; }
.bar-track { height: 28px; background: #e8eef6; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--blue); min-width: 4px; display: flex; justify-content: flex-end; align-items: center; color: white; padding-right: 8px; font-weight: 700; font-size: 13px; }
.bar.normalized .bar-fill { opacity: .62; }
.bar strong em {
  margin-left: 4px;
  font-style: normal;
  color: var(--muted);
}
.bar:nth-child(2) .bar-fill { background: var(--violet); }
.bar:nth-child(3) .bar-fill { background: var(--green); }
.bar:nth-child(4) .bar-fill { background: var(--amber); }
.bar:nth-child(5) .bar-fill { background: var(--pink); }
table { width: 100%; border-collapse: collapse; }
th { background: #dff0fb; color: #075985; text-align: left; font-size: 12px; letter-spacing: .04em; }
td, th { padding: 12px 14px; border-bottom: 1px solid var(--line); }
tr.selected td { background: #eff6ff; }
.tables-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
}
.tables-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 10px;
  position: relative;
  z-index: 3;
}
.tables-toolbar label {
  min-width: 220px;
}
.tables-search {
  width: min(420px, 38vw);
  min-height: 38px;
}
.tables-flow-filter {
  min-width: 230px;
}
.tables-toolbar input,
.tables-toolbar select {
  min-height: 38px;
}
.table-select {
  position: relative;
}
.table-select > button {
  min-width: 150px;
  min-height: 38px;
  font-weight: 800;
}
.table-mode-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 190px;
  display: grid;
  gap: 6px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, .18);
}
.table-tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: #f8fafc;
}
.table-tab.active {
  background: #e0edff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 800;
}
.tables-main,
.table-editor-panel {
  min-width: 0;
}
.tables-main {
  padding: 12px;
  overflow: hidden;
}
.table-scroll {
  overflow: auto;
  height: calc(100vh - 144px);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.table-scroll table {
  min-width: 900px;
}
.table-scroll tbody tr {
  cursor: pointer;
}
.table-scroll tbody tr:hover td {
  background: #f8fafc;
}
.table-scroll td small {
  display: block;
  margin-top: 4px;
}
.table-empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 34px 16px;
}
.table-empty-cell button {
  margin-left: 12px;
}
.table-editor-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  z-index: 20;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.table-editor-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}
.table-editor,
.table-editor-empty {
  display: grid;
  gap: 12px;
}
.table-editor input,
.table-editor select,
.table-editor textarea {
  width: 100%;
  min-width: 0;
}
.table-editor textarea {
  min-height: 94px;
  resize: vertical;
}
.table-editor-empty {
  color: var(--muted);
  min-height: 180px;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.lead-flow-summary {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.lead-flow-summary span {
  font-size: 12px;
  color: var(--ink);
}
.utm-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  padding: 0;
  padding-left: calc(var(--utm-level, 0) * 22px);
  color: var(--ink);
}
.utm-toggle.leaf {
  cursor: default;
}
.utm-caret {
  width: 14px;
  color: #64748b;
  flex: 0 0 14px;
  text-align: center;
}
.utm-row.level-0 td:first-child strong { font-size: 15px; }
.utm-row.level-1 td:first-child strong { font-weight: 700; }
.utm-row.level-2 td:first-child strong,
.utm-row.level-3 td:first-child strong { font-weight: 500; }

.chat { height: 310px; overflow: auto; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 10px; align-content: start; }
.bubble { max-width: 86%; padding: 10px 12px; border-radius: 8px; background: white; border: 1px solid var(--line); }
.bubble.me { justify-self: end; background: #e0f2fe; }
.bubble .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bubble .actions button { padding: 7px 9px; background: #dcfce7; }
.chat-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }

.builder-toolbar {
  display: flex; gap: 8px; align-items: end; background: white; border: 1px solid var(--line);
  padding: 8px; border-radius: 8px; margin-bottom: 8px; flex-wrap: wrap;
  flex-shrink: 0;
}
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
label input, label textarea, label select { min-width: 160px; color: var(--ink); }
.builder-toolbar label {
  gap: 3px;
  font-size: 11px;
}
.builder-toolbar input,
.builder-toolbar select,
.builder-toolbar button {
  min-height: 38px;
  padding: 8px 10px;
}
.builder-toolbar #flowName { width: 190px; min-width: 150px; }
.builder-toolbar #flowTrigger { width: 150px; min-width: 120px; }
.builder-toolbar #flowBot { width: 170px; min-width: 140px; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.toggle input { min-width: auto; }
.flow-active-toggle {
  min-width: 104px;
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #475569;
  font-weight: 800;
}
.flow-active-toggle.active {
  border-color: #86efac;
  background: #dcfce7;
  color: #047857;
}
.flow-menu {
  position: relative;
}
.flow-menu > button {
  min-width: 92px;
}
.flow-list-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: 300px;
  max-height: min(520px, calc(100vh - 180px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
}
.flow-list-popover.hidden {
  display: none;
}
.flow-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.flow-list-head #duplicateFlowBtn {
  margin-left: auto;
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}
.flow-link-preview {
  display: none;
  gap: 3px;
  min-width: 280px;
  max-width: 420px;
  padding: 8px 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fafc;
}
.flow-link-preview span {
  color: var(--muted);
  font-size: 11px;
}
.flow-link-preview code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1d4ed8;
  font-size: 12px;
}
.transport-form {
  display: grid;
  gap: 12px;
}
.transport-form .compact-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.telegram-transport {
  align-content: start;
}
.webhook-preview {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fafc;
}
.webhook-preview span {
  color: var(--muted);
  font-size: 11px;
}
.webhook-preview code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1d4ed8;
  font-size: 12px;
}
.transport-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.transport-status {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.transport-status span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.builder-shell { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; }
.builder-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}
.builder-workbench.inspector-closed {
  grid-template-columns: minmax(0, 1fr);
}
.builder-flow-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
}
.builder-flow-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 10px;
  background: #f8fafc;
}
.builder-flow-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .14);
  background: white;
}
.builder-flow-item strong,
.builder-flow-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-flow-item strong {
  color: var(--ink);
  font-size: 13px;
}
.builder-flow-item small {
  color: var(--muted);
  margin-top: 3px;
  font-size: 11px;
}
.builder-flow-item em {
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  padding: 4px 7px;
}
.builder-flow-item em.is-active {
  background: #dcfce7;
  color: #047857;
}
.canvas-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.canvas {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 24px 24px; background-color: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  cursor: grab;
}
.canvas.panning { cursor: grabbing; }
.selection-box {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  border: 1px solid #2563eb;
  background: rgba(37, 99, 235, .12);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, .08) inset;
}
#edgesSvg { position: absolute; left: 0; top: 0; width: 2200px; height: 1200px; pointer-events: none; z-index: 2; overflow: visible; }
.edge-underlay-path {
  stroke: rgba(255,255,255,.94);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.edge-path {
  pointer-events: stroke;
  cursor: pointer;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px rgba(15,23,42,.18));
}
.edge-hit-path {
  pointer-events: stroke;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}
.selected-edge-path {
  stroke-width: 5 !important;
  filter: drop-shadow(0 0 5px rgba(37,99,235,.35));
}
#nodesLayer { position: relative; width: 2200px; height: 1200px; pointer-events: none; z-index: 3; transform-origin: 0 0; }
#edgesSvg { transform-origin: 0 0; }
.node {
  position: absolute; width: 260px; min-height: 130px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: white; box-shadow: 0 10px 24px rgba(15,23,42,.08); padding: 0; cursor: grab;
  pointer-events: auto;
}
.node.selected { outline: 3px solid rgba(37,99,235,.25); border-color: var(--blue); }
.node.selected::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px dashed rgba(37, 99, 235, .62);
  border-radius: 10px;
  pointer-events: none;
}
.node.connect-mode-node { cursor: crosshair; }
.node.connect-mode-node::after {
  content: "";
  position: absolute;
  right: -11px;
  top: 46px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid white;
  box-shadow: 0 3px 10px rgba(37,99,235,.35);
}
.node.connect-source {
  outline: 3px solid rgba(5,150,105,.25);
  border-color: #059669;
}
.node.connect-mode-node::after { display: none; }
.node.start { border-left: 5px solid var(--green); }
.node.message { border-left: 5px solid var(--blue); }
.node.event { border-left: 5px solid #7c3aed; }
.node-port {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px solid white;
  box-shadow: 0 3px 9px rgba(15,23,42,.22);
}
.node-port.in {
  left: -14px;
  top: 48px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #64748b;
}
.node-output-ports {
  position: absolute;
  right: -14px;
  top: 42px;
  display: grid;
  gap: 10px;
  z-index: 6;
}
.node-port.out {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  padding: 0;
  cursor: crosshair;
  font-size: 0;
}
.node-port::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}
.node-port:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 5px rgba(37,99,235,.14), 0 3px 9px rgba(15,23,42,.22);
}
.node-port.out span {
  display: none;
  pointer-events: none;
}
.port-auto,
.port-true {
  background: #059669;
}
.port-false {
  background: #e11d48;
}
.node-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; margin-bottom: 8px; }
.node-text { color: #334155; font-size: 13px; line-height: 1.35; max-height: 80px; overflow: hidden; white-space: pre-wrap; }
.node-buttons { display: grid; gap: 5px; margin-top: 10px; }
.node-buttons span { background: #dcfce7; border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.event-node-shell {
  background: linear-gradient(180deg, #faf5ff 0%, #fff 100%);
}
.event-node-body {
  display: grid;
  gap: 6px;
  margin: 10px 12px;
  padding: 14px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: white;
}
.event-node-body strong {
  color: #4c1d95;
}
.event-node-body span {
  color: #64748b;
  font-size: 12px;
}
.tg-board-node {
  background: #f8fafc;
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(15,23,42,.10);
  overflow: visible;
}
.tg-board-node.message {
  border-left: 0;
}
.tg-board-node.start {
  border-left: 0;
}
.board-node-shell {
  position: relative;
  padding: 10px;
}
.tg-board-node.message .board-node-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.board-node-head {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #2563eb;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 0 4px 8px;
}
.board-node-head > span:first-child { margin-right: auto; }
.tg-head-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  background: #dbeafe;
  border: 1px solid #93c5fd;
}
.board-stage-pill {
  max-width: 165px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 8px;
  background: #2563eb;
  color: white;
  text-transform: none;
  letter-spacing: 0;
}
.reminder-node-toggle {
  justify-content: start;
}
.hidden {
  display: none !important;
}
.board-head-actions {
  border-radius: 7px;
  padding: 4px 7px;
  background: #eef2f7;
  color: #64748b;
  text-transform: none;
  letter-spacing: 0;
}
.node-kind {
  color: #6d4cff;
}
.start-kind {
  color: #10b981;
}
.board-title-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  padding: 5px 4px 7px;
  font-weight: 800;
  font-size: 14px;
  background: transparent;
}
.board-title-label {
  padding: 0 4px 8px;
  font-weight: 800;
  font-size: 12px;
  color: #64748b;
  display: none;
}
.board-title-input:read-only {
  pointer-events: none;
}
.tg-card {
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15,23,42,.06);
}
.tg-board-node.message .tg-card {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.board-message-text {
  padding: 10px 10px 8px;
  font-size: 15px;
  line-height: 1.42;
  font-weight: 400;
  color: #020617;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: white;
  max-height: none;
  overflow: visible;
}
.board-message-text blockquote,
.tg-bubble-text blockquote {
  position: relative;
  margin: 10px 0 12px;
  padding: 9px 28px 9px 11px;
  border-left: 3px solid #27a7f8;
  background: #e8f7ff;
  border-radius: 0 8px 8px 0;
  color: #0f172a;
  line-height: 1.38;
}
.board-message-text blockquote::after,
.tg-bubble-text blockquote::after {
  content: "”";
  position: absolute;
  right: 8px;
  top: 6px;
  color: #27a7f8;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.board-textarea {
  width: 100%;
  min-width: 0;
  min-height: 150px;
  border: 0;
  border-radius: 0;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.36;
  resize: vertical;
  background: white;
}
.board-media-img {
  width: 100%;
  height: auto;
  max-height: min(260px, 46vh);
  object-fit: contain;
  display: block;
  background: #e2e8f0;
}
.board-video-frame {
  position: relative;
  width: min(58%, 180px);
  aspect-ratio: 9 / 16;
  margin: 10px auto 0;
  overflow: hidden;
  border-radius: 12px;
  background: #111827;
}
.board-video-preview,
.board-video-poster,
.board-video-loading {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.board-video-note-frame {
  position: relative;
  width: min(56%, 150px);
  aspect-ratio: 1 / 1;
  margin: 12px auto 0;
  overflow: hidden;
  border-radius: 50%;
  background: #111827;
}
.board-video-note-preview,
.board-video-note-frame .board-video-poster,
.board-video-note-frame .board-video-loading {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.board-video-loading {
  background:
    linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.16), rgba(255,255,255,0)),
    #1f2937;
  background-size: 200% 100%;
  animation: mediaLoading 1.1s linear infinite;
}
@keyframes mediaLoading {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.board-video-frame .board-play,
.board-video-note-frame .board-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.board-media-placeholder {
  min-height: 132px;
  display: grid;
  gap: 5px;
  place-items: center;
  text-align: center;
  color: #475569;
  background: linear-gradient(135deg, #e0f2fe, #eef2ff);
}
.board-media-placeholder.video-note-placeholder {
  width: min(56%, 150px);
  aspect-ratio: 1 / 1;
  min-height: 0;
  margin: 12px auto 0;
  border-radius: 50%;
  overflow: hidden;
}
.board-media-placeholder strong {
  font-size: 12px;
  color: #1d4ed8;
}
.board-media-placeholder small {
  max-width: 92%;
  overflow-wrap: anywhere;
}
.board-audio-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 10px 12px 0;
  padding: 12px;
  border-radius: 9px;
  background: linear-gradient(135deg, #dbeafe, #ecfeff);
  border: 1px solid #bfdbfe;
}
.board-audio-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  font-weight: 900;
  font-size: 20px;
}
.board-audio-card strong,
.board-audio-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-audio-card strong {
  color: #0f172a;
  font-size: 13px;
}
.board-audio-card small {
  color: #475569;
  margin-top: 2px;
}
.board-play {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: rgba(15, 23, 42, .78);
}
.board-inline-buttons {
  display: grid;
  gap: 6px;
  padding: 8px 14px 10px;
  background: white;
}
.board-inline-buttons button {
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  color: #15803d;
  background: #cdeed2;
  font-size: 12px;
  font-weight: 700;
}
.board-message-time {
  padding: 0 10px 8px;
  color: #94a3b8;
  text-align: right;
  font-size: 10px;
  background: white;
}
.board-inline-buttons.editable {
  gap: 6px;
}
.board-button-edit {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 5px;
  padding: 6px;
  border-radius: 7px;
  background: white;
  border: 1px solid #dce7f4;
}
.board-button-edit input,
.board-button-edit select {
  width: 100%;
  min-width: 0;
  padding: 6px;
  font-size: 11px;
}
.board-button-edit input:last-child {
  grid-column: 1 / -1;
}
.board-add-button {
  border: 1px dashed #93c5fd !important;
  background: #f8fbff !important;
}
.board-edit-strip {
  display: grid;
  gap: 6px;
  margin-top: 7px;
  padding: 7px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #dce7f4;
}
.board-edit-strip label {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 6px;
}
.board-edit-strip input,
.board-edit-strip select {
  width: 100%;
  min-width: 0;
  padding: 6px;
  font-size: 11px;
}
.board-node-foot {
  display: flex;
  justify-content: space-between;
  color: #6b88ad;
  font-size: 10px;
  padding: 7px 2px 0;
  flex: 0 0 auto;
}
.node-resize-handle {
  position: absolute;
  z-index: 8;
  background: rgba(37,99,235,.18);
}
.resize-right {
  right: -4px;
  top: 34px;
  width: 8px;
  bottom: 20px;
  cursor: ew-resize;
}
.resize-bottom {
  left: 18px;
  right: 18px;
  bottom: -4px;
  height: 8px;
  cursor: ns-resize;
}
.resize-corner {
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(15,23,42,.22);
  cursor: nwse-resize;
}
.start-command {
  border: 1px solid #dce7f4;
  border-radius: 7px;
  background: white;
  padding: 12px;
  font-size: 12px;
  color: #475569;
}
.editing-on-board {
  z-index: 3;
}
.inspector { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 12px; align-content: start; }
.inspector textarea { min-height: 120px; resize: vertical; }
.telegram-editor {
  min-height: 0;
  overflow: auto;
}
.phone-panel {
  display: none;
}
.publish-state {
  margin-left: auto;
  align-self: end;
  padding: 8px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #047857;
  font-size: 11px;
  font-weight: 800;
  max-width: 300px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.publish-state.dirty { background: #fef3c7; color: #92400e; }
.telegram-editor,
.phone-panel {
  display: block;
  position: sticky;
  top: 96px;
}
.phone-panel {
  display: none;
}
.builder-workbench > .telegram-editor {
  display: block;
  position: static;
  top: auto;
  height: 100%;
  min-height: 0;
  overflow: auto;
}
.editor-grid {
  display: grid;
  gap: 12px;
}
#nodeInspector.edge-only > :not(#edgeList) {
  display: none !important;
}
#nodeInspector.event-only .reminder-node-toggle,
#nodeInspector.event-only .format-toolbar,
#nodeInspector.event-only .message-text-label,
#nodeInspector.event-only .media-box,
#nodeInspector.event-only .buttons-head,
#nodeInspector.event-only #buttonEditor {
  display: none !important;
}
.compact-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.node-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.danger {
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}
.danger:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.format-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.format-toolbar button {
  min-width: 38px;
  padding: 8px 10px;
  font-weight: 800;
  background: #f8fafc;
}
.telegram-editor textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}
.text-counter {
  margin-top: -4px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.text-counter.limit-near {
  color: #b45309;
}
.text-counter.limit-over {
  color: #dc2626;
  font-weight: 700;
}
.media-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.media-library-actions,
.media-upload-row,
.media-fileid-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}
.media-picker,
.media-upload-row input,
.media-fileid-row input {
  min-width: 0;
}
.media-picker {
  position: relative;
}
.media-picker-current,
.media-picker-option {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 7px;
  text-align: left;
  background: white;
  border: 1px solid #dce7f4;
  border-radius: 8px;
}
.media-picker-current.empty {
  color: var(--muted);
}
.media-picker-current strong,
.media-picker-current small,
.media-picker-option strong,
.media-picker-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-picker-current small,
.media-picker-option small {
  color: var(--muted);
}
.media-picker-chevron {
  color: var(--muted);
  font-size: 18px;
}
.media-picker-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  max-height: 220px;
  padding: 6px;
  overflow: auto;
  background: white;
  border: 1px solid #cfe0f3;
  border-radius: 9px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}
.media-picker-option {
  grid-template-columns: 52px minmax(0, 1fr);
  border-color: transparent;
}
.media-picker-option:hover,
.media-picker-option.selected {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.media-library-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}
.media-library-selected {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  background: white;
  border: 1px solid #dce7f4;
  border-radius: 8px;
  padding: 7px;
}
.media-library-selected strong,
.media-library-selected small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-library-selected small {
  color: var(--muted);
}
.media-library-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 4px 8px;
  text-align: left;
  background: white;
  border: 1px solid #dce7f4;
  padding: 8px;
}
.media-library-thumb,
.media-library-selected-thumb {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 38px;
  overflow: hidden;
  border-radius: 7px;
  background: #eef2ff;
  color: #3730a3;
}
.media-library-selected-thumb {
  grid-row: auto;
}
.media-library-thumb img,
.media-library-thumb video,
.media-library-selected-thumb img,
.media-library-selected-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-library-thumb b,
.media-library-selected-thumb b {
  font-size: 16px;
  line-height: 1;
}
.media-library-thumb .media-row-placeholder {
  font-size: 13px;
}
.media-library-item strong,
.media-library-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-library-item small {
  color: var(--muted);
}
.media-page-layout {
  display: grid;
  gap: 16px;
}
.media-uploader-panel {
  position: sticky;
  top: 92px;
  z-index: 2;
}
.media-page-tools {
  display: grid;
  grid-template-columns: 180px minmax(240px, 1fr) minmax(360px, 1.3fr);
  gap: 10px;
  align-items: end;
}
.media-page-status {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}
.media-page-status.success { color: #047857; }
.media-page-status.error { color: #b91c1c; }
.media-page-status.info { color: #1d4ed8; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.media-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(15,23,42,.05);
}
.media-preview {
  height: 210px;
  background: #e8eef6;
  display: grid;
  place-items: center;
}
.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-audio-preview,
.media-placeholder-preview {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  background: linear-gradient(135deg, #e0f2fe, #eef2ff);
  color: #1e3a8a;
}
.media-audio-preview audio {
  width: min(260px, 92%);
}
.media-placeholder-preview small {
  color: #475569;
  overflow-wrap: anywhere;
}
.media-card-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.media-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.media-card-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-card-head span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf2ff;
  color: #3730a3;
  font-size: 12px;
}
.media-links {
  display: grid;
  gap: 8px;
  margin: 0;
}
.media-links div {
  display: grid;
  gap: 4px;
}
.media-links dt {
  color: var(--muted);
  font-size: 12px;
}
.media-links dd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin: 0;
}
.media-links input {
  min-width: 0;
  font-size: 12px;
}
.media-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.media-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.media-card-actions .danger {
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}
.empty-media-card {
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 8px;
}
.media-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(15,23,42,.05);
}
.media-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.media-list-head span {
  color: var(--muted);
  font-size: 13px;
}
.media-row {
  background: white;
  border-bottom: 1px solid #edf2f7;
}
.media-row:last-child {
  border-bottom: 0;
}
.media-row-main {
  display: grid;
  grid-template-columns: 50px minmax(180px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
}
.media-row-preview {
  width: 48px;
  height: 36px;
  overflow: hidden;
  border-radius: 7px;
  background: #111827;
}
.media-row-preview .media-preview {
  width: 100%;
  height: 100%;
}
.media-row-preview img,
.media-row-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-row-video-thumb {
  pointer-events: none;
  background: #111827;
}
.media-row-preview:has(.media-row-round-thumb) {
  width: 42px;
  height: 42px;
  border-radius: 999px;
}
.media-row-round-thumb {
  border-radius: 999px;
}
.media-row-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e0f2fe, #eef2ff);
  color: #1e3a8a;
  font-weight: 800;
  font-size: 16px;
}
.media-row-preview .media-audio-preview,
.media-row-preview .media-placeholder-preview {
  width: 100%;
  height: 100%;
  padding: 0;
  font-size: 10px;
}
.media-row-preview audio,
.media-row-preview small {
  display: none;
}
.media-row-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.media-row-info strong,
.media-row-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-row-info small {
  color: var(--muted);
  font-size: 12px;
}
.media-type-pill,
.media-fileid-state {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  white-space: nowrap;
}
.media-type-pill.type-video_note {
  background: #fce7f3;
  color: #be185d;
}
.media-type-pill.type-video {
  background: #e0f2fe;
  color: #0369a1;
}
.media-fileid-state {
  background: #fff7ed;
  color: #c2410c;
}
.media-fileid-state.ready {
  background: #dcfce7;
  color: #047857;
}
.media-row-actions {
  display: flex;
  gap: 6px;
}
.media-row-actions button {
  padding: 7px 9px;
}
.media-row-actions .danger {
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}
.media-row-details {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px minmax(220px, 1.4fr) minmax(220px, 1.4fr) auto;
  gap: 8px;
  align-items: end;
  padding: 10px 16px 14px 76px;
  background: #f8fafc;
  border-top: 1px solid #edf2f7;
}
.media-row-details label,
.media-row-details input,
.media-row-details select {
  min-width: 0;
}
.buttons-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.buttons-head h3,
.telegram-editor h3 {
  margin: 0;
  font-size: 14px;
}
.button-editor {
  display: grid;
  gap: 8px;
}
.button-row {
  display: grid;
  grid-template-columns: 1.1fr .82fr 1.2fr 38px;
  gap: 6px;
}
.button-row input,
.button-row select,
.button-row button {
  min-width: 0;
  padding: 8px;
}
.button-row button {
  color: #b91c1c;
  background: #fff1f2;
}
.condition-editor {
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
}
.condition-editor select {
  width: 100%;
}
.phone-frame {
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
  background: #0f172a;
  border-radius: 28px;
  padding: 12px;
  box-shadow: 0 22px 46px rgba(15,23,42,.22);
}
.tg-header {
  height: 58px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: white;
  padding: 0 10px;
}
.tg-header span {
  display: block;
  color: #93c5fd;
  font-size: 12px;
  margin-top: 2px;
}
.tg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  font-weight: 900;
}
.tg-chat-bg {
  min-height: 520px;
  border-radius: 18px;
  padding: 16px 10px;
  background:
    linear-gradient(rgba(229, 244, 255, .8), rgba(218, 239, 232, .8)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.45) 0 8px, rgba(255,255,255,.18) 8px 16px);
}
.tg-message {
  max-width: 92%;
  background: white;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 2px 6px rgba(15,23,42,.13);
  overflow: hidden;
}
.tg-bubble-text {
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.36;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tg-bubble-text a { color: #2481cc; }
.tg-bubble-text code {
  background: #eef2f7;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: Consolas, monospace;
  font-size: 13px;
}
.tg-time {
  float: right;
  margin-left: 8px;
  color: #7aa6bd;
  font-size: 11px;
  transform: translateY(4px);
}
.tg-media {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  background: #dbeafe;
}
.tg-media-placeholder {
  display: grid;
  place-items: center;
  min-height: 155px;
  padding: 18px;
  text-align: center;
  color: #1e3a8a;
  background: linear-gradient(135deg, #dbeafe, #dcfce7);
  font-weight: 800;
}
.tg-media-placeholder small {
  color: #475569;
  font-weight: 500;
  margin-top: 6px;
}
.tg-inline-buttons {
  display: grid;
  gap: 1px;
  padding: 0 6px 6px;
}
.tg-inline-buttons button {
  color: #2481cc;
  background: #f8fbff;
  border: 0;
  border-radius: 6px;
  padding: 9px;
}
.bubble .tg-inline-buttons {
  padding: 8px 0 0;
}
.bubble .tg-media,
.bubble .tg-media-placeholder {
  border-radius: 7px;
  margin-bottom: 8px;
}
.hidden { display: none; }
.muted { color: var(--muted); }
.edge-list { display: grid; gap: 8px; }
.edge-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; }
.edge-row select, .edge-row input { width: 100%; padding: 8px; }
.edge-summary-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 8px;
  width: 100%;
  padding: 10px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.edge-summary-row span {
  color: var(--muted);
  font-size: 12px;
}
.edge-summary-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.edge-summary-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}
.edge-summary-row:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.edge-settings-card {
  display: grid;
  gap: 9px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px;
  background: #f8fbff;
}
.edge-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.edge-settings-head button {
  width: 32px;
  height: 32px;
  padding: 0;
}
.edge-settings-card .danger {
  color: #b91c1c;
  background: #fff1f2;
  border-color: #fecdd3;
}
.reminder-edge-row { border-color: #fecaca; background: #fff7f7; }
.edge-reminder-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #991b1b;
  font-weight: 700;
}
.edge-reminder-toggle input { width: auto; min-width: auto; }
.edge-reminder-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.edge-delay-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.edge-reminder-fields label,
.edge-reminder-fields select,
.edge-reminder-fields input,
.edge-delay-fields label,
.edge-delay-fields select,
.edge-delay-fields input {
  min-width: 0;
}
.transport { min-height: 190px; display: grid; gap: 12px; align-content: start; }
code { background: #eef2ff; padding: 2px 5px; border-radius: 5px; }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .two, .three, .builder-shell, .builder-workbench, .ecosystem-stage, .journey-strip { grid-template-columns: 1fr; }
  .canvas { height: 560px; }
  .stage-copy h2 { font-size: 32px; }
  .journey-step::after { display: none; }
  .telegram-editor, .phone-panel { position: static; }
  .media-page-tools { grid-template-columns: 1fr; }
}
.table-row-context-menu {
  position: fixed;
  z-index: 80;
  min-width: 180px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.table-row-context-menu__danger {
  width: 100%;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #dc2626;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.table-row-context-menu__danger:hover {
  background: #ffe4e6;
}
