/* ==========================================================================
   Конструктор Telegram-ботов — панель
   Спокойная рабочая поверхность + три «сигнальных» цвета Telegram-кнопок
   (синий / зелёный / красный), которые и в самой панели значат то же самое.
   ========================================================================== */

:root {
  --paper: #f1f2ee;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --surface-3: #eceee9;
  --ink: #17202b;
  --ink-2: #4c5764;
  --ink-3: #87909a;
  --line: #d9ddd9;
  --line-2: #e7eae6;
  --blue: #2d7be2;
  --blue-hover: #1f6acd;
  --blue-soft: #e4eefb;
  --green: #22a058;
  --green-hover: #1b8a4b;
  --green-soft: #e1f3e8;
  --red: #dc4a3f;
  --red-hover: #c33a30;
  --red-soft: #fbe6e4;
  --amber: #c98314;
  --amber-soft: #fbf0db;
  --night: #17212b;
  --night-2: #0e1621;
  --night-3: #202b38;
  --night-ink: #e9edf1;
  --night-ink-2: #8796a6;
  --shadow-1: 0 1px 2px rgba(23, 32, 43, 0.06);
  --shadow-2: 0 8px 28px rgba(23, 32, 43, 0.14), 0 2px 6px rgba(23, 32, 43, 0.06);
  --focus: 0 0 0 3px rgba(45, 123, 226, 0.32);
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --tg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rail-w: 212px;
  --topbar-h: 58px;
  /* логотип «Кубик»: чёрный знак на светлом фоне, жёлтый — на тёмном */
  --brand-mark: #000000;
  --brand-ink: #000000;
  --brand-yellow: #ffc21a;
  --brand-font: "Wix Madefor Display", "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171d;
    --surface: #1a2027;
    --surface-2: #1f262e;
    --surface-3: #262e37;
    --ink: #e8ecef;
    --ink-2: #aeb7c0;
    --ink-3: #7a8591;
    --line: #2f3843;
    --line-2: #28303a;
    --blue: #4b91ee;
    --blue-hover: #6aa4f2;
    --blue-soft: #1d2e44;
    --green: #35b56c;
    --green-hover: #4cc47e;
    --green-soft: #183527;
    --red: #e8645a;
    --red-hover: #ef7d74;
    --red-soft: #3c1f1d;
    --amber: #e3a23e;
    --amber-soft: #3a2d16;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45);
    --brand-mark: var(--brand-yellow);
    --brand-ink: var(--ink);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
#app > * {
  flex: 1 0 auto;
}
body {
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 15px;
}
p {
  margin: 0 0 8px;
}
code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
[hidden] {
  display: none !important;
}
.muted {
  color: var(--ink-2);
}
.danger-text {
  color: var(--red);
}
.faint {
  color: var(--ink-3);
}
.small {
  font-size: 12.5px;
}
.nowrap {
  white-space: nowrap;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.top {
  align-items: flex-start;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stack.tight {
  gap: 6px;
}
.spacer {
  flex: 1;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.sm {
  width: 15px;
  height: 15px;
}
.icon.lg {
  width: 22px;
  height: 22px;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-m);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn.primary:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
}
.btn.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn.success:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
}
.btn.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn.danger:hover {
  background: var(--red-hover);
}
.btn.danger-text {
  color: var(--red);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--surface-3);
  border-color: transparent;
}
.btn.sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--r-s);
}
.btn.icon-only {
  width: 36px;
  padding: 0;
}
.btn.sm.icon-only {
  width: 30px;
}
.btn.block {
  width: 100%;
}
.btn .badge {
  margin-left: 2px;
}

/* ------------------------------------------------------------------ forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field > label,
.label {
  font-weight: 550;
  font-size: 13px;
  color: var(--ink-2);
}
.hint {
  font-size: 12.5px;
  color: var(--ink-3);
}
.input,
select.input,
textarea.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--r-m);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.input {
  height: auto;
  min-height: 84px;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.45;
}
.input:hover {
  border-color: var(--ink-3);
}
.input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--focus);
}
.input.invalid {
  border-color: var(--red);
}
.input.sm {
  height: 30px;
  font-size: 13px;
  border-radius: var(--r-s);
}
select.input {
  padding-right: 30px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2387909a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group > .input:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-group > .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}
.prefix-input {
  position: relative;
}
.prefix-input > span {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.prefix-input > .input {
  padding-left: 24px;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch .track {
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  flex: none;
  transition: background-color 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked + .track {
  background: var(--green);
}
.switch input:checked + .track::after {
  transform: translateX(15px);
}
.switch input:focus-visible + .track {
  box-shadow: var(--focus);
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-m);
  background: var(--surface-3);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 13px;
  white-space: nowrap;
}
.seg button:hover {
  color: var(--ink);
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ------------------------------------------------------------------ chips & badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.badge.green {
  background: var(--green-soft);
  color: var(--green);
}
.badge.red {
  background: var(--red-soft);
  color: var(--red);
}
.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.dot.green {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.dot.red {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.dot.amber {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}
.kbd {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.panel-body {
  padding: 16px 18px;
}
.section {
  padding: 18px 0;
  border-top: 1px solid var(--line-2);
}
.section:first-child {
  border-top: 0;
  padding-top: 4px;
}
.section > h3 {
  margin-bottom: 4px;
}
.section-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty h3 {
  color: var(--ink);
  margin-bottom: 6px;
}
.empty .btn {
  margin-top: 14px;
}
.callout {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: 13px;
}
.callout.blue {
  background: var(--blue-soft);
  border-color: transparent;
  color: var(--ink);
}
.callout.amber {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--ink);
}
.callout.red {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--ink);
}
.callout.green {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--ink);
}
.callout .icon {
  margin-top: 1px;
}
/* две колонки полей в настройках; на телефоне — одна */
.form-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}
.form-pair-action .btn {
  align-self: flex-start;
}
@media (max-width: 560px) {
  .form-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------------ table */
.table-wrap {
  overflow-x: auto;
  position: relative; /* скрытые подписи (sr-only) внутри таблицы не расширяют страницу */
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-2);
  font-size: 12.5px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
.table tr.clickable {
  cursor: pointer;
}
.table tr.clickable:hover td {
  background: var(--surface-2);
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 22, 33, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
  animation: fade-in 0.12s ease-out;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: rise 0.16s ease-out;
}
.modal.wide {
  width: min(820px, 100%);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 6px;
}
.modal-head h2 {
  flex: 1;
}
.modal-body {
  padding: 10px 20px 18px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line-2);
}
.drawer-overlay {
  justify-content: flex-end;
  padding: 0;
}
.drawer {
  width: min(480px, 100%);
  height: 100%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: slide-in 0.18s ease-out;
}
.popover {
  position: fixed;
  z-index: 120;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
  animation: fade-in 0.1s ease-out;
}
.menu {
  padding: 5px;
  min-width: 200px;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
}
.menu button:hover {
  background: var(--surface-3);
}
.menu button.danger {
  color: var(--red);
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--line-2);
  margin: 4px 0;
}
.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--night);
  color: #fff;
  box-shadow: var(--shadow-2);
  font-weight: 500;
  animation: rise 0.16s ease-out;
}
.toast.error {
  background: #8e2a23;
}
.toast.success .icon {
  color: #5fd38d;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes slide-in {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ auth */
.auth {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(340px, 480px) 1fr;
}
.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 5vw, 64px);
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-mark {
  display: block;
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--brand-mark);
}
.auth-form .brand {
  gap: 12px;
}
.auth-form .brand-mark {
  width: 46px;
  height: 46px;
}
.auth-form .brand-name {
  font-size: 34px;
}
.auth-form h1 {
  font-size: 28px;
  margin: 34px 0 8px;
  letter-spacing: -0.02em;
}
.auth-form form {
  margin-top: 26px;
}
.auth-switch {
  margin-top: 16px;
  color: var(--ink-2);
}
.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
/* значок результата на страницах по ссылкам из писем */
.auth-done {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-top: 30px;
  background: var(--brand-yellow);
  color: #000;
}
.auth-done .icon {
  width: 26px;
  height: 26px;
}
.auth-done.green {
  background: var(--green-soft);
  color: var(--green);
}
.auth-done.red {
  background: var(--red-soft);
  color: var(--red);
}
.auth-done + h1 {
  margin-top: 18px;
}
.auth-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--night);
  overflow: hidden;
  padding: 40px 24px;
}
.auth-stage .phone {
  transform: rotate(-2deg);
  height: min(700px, calc(100vh - 110px));
  min-height: 480px;
}
.auth-note {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--night-ink-2);
  font-size: 13px;
}

/* ------------------------------------------------------------------ app shell */
.shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .bot-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar .bot-id .names {
  min-width: 0;
  line-height: 1.2;
}
.topbar .bot-id strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .bot-id span {
  font-size: 12.5px;
  color: var(--ink-3);
}
.save-state {
  font-size: 12.5px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  font-size: 14px;
  background: linear-gradient(140deg, #5aa3f5, #2d6fd8);
}
.avatar.lg {
  width: 44px;
  height: 44px;
  font-size: 17px;
}
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 0;
}
.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 10px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 550;
  text-decoration: none;
}
.rail a:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.rail a.on {
  background: var(--blue-soft);
  color: var(--blue);
}
.rail a .count {
  margin-left: auto;
}
.rail .rail-sep {
  height: 1px;
  background: var(--line-2);
  margin: 10px 6px;
}
.main {
  min-width: 0;
  padding: 22px clamp(16px, 2.6vw, 34px) 60px;
}
.main.flush {
  padding: 0;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin-right: auto;
}
.narrow {
  max-width: 820px;
}

/* ------------------------------------------------------------------ bots list */
.home {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 40px) 60px;
}
.bot-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  overflow: hidden;
}
.bot-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-2);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.bot-item:first-child {
  border-top: 0;
}
.bot-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.bot-item .names strong {
  display: block;
  font-size: 15px;
}
.bot-item .names span {
  color: var(--ink-3);
  font-size: 13px;
}
.bot-item .metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bot-item .metric b {
  display: block;
  font-size: 15px;
}
.bot-item .metric span {
  font-size: 12px;
  color: var(--ink-3);
}
.template-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.template-option {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  cursor: pointer;
}
.template-option:hover {
  border-color: var(--ink-3);
}
.template-option.on {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  background: var(--blue-soft);
}
.template-option strong {
  display: block;
}
.template-option span {
  font-size: 12.5px;
  color: var(--ink-2);
}
.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
}
.steps li {
  margin: 3px 0;
}

/* ------------------------------------------------------------------ scenario editor */
.studio {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 420px;
  height: calc(100vh - var(--topbar-h));
  min-height: 560px;
}
.studio-tabs {
  display: none;
}
.screens-col {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screens-col .col-head {
  padding: 12px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line-2);
}
.screen-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.screen-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
  border: 1px solid transparent;
}
.screen-item:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.screen-item.on {
  background: var(--blue-soft);
  color: var(--ink);
  border-color: rgba(45, 123, 226, 0.25);
}
.screen-item .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.screen-item .icon {
  color: var(--ink-3);
}
.screen-item .start-mark {
  color: var(--amber);
}
.screen-item .issue {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}
.screen-item .issue.warn {
  background: var(--amber);
}
.flow-hint {
  padding: 10px 12px;
  border-top: 1px solid var(--line-2);
  font-size: 12px;
  color: var(--ink-3);
}
.editor-col {
  overflow-y: auto;
  min-height: 0;
  padding: 18px clamp(16px, 2vw, 28px) 80px;
}
.screen-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.screen-title input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font-size: 20px;
  font-weight: 650;
  padding: 4px 0;
  letter-spacing: -0.01em;
}
.screen-title input:hover {
  border-bottom-color: var(--line);
}
.screen-title input:focus {
  outline: none;
  border-bottom-color: var(--blue);
  box-shadow: none;
}
.screen-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--ink-3);
  font-size: 12.5px;
  margin-bottom: 14px;
}
.block {
  padding: 16px 0;
  border-top: 1px solid var(--line-2);
}
.block-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.block-head h3 {
  margin-right: auto;
}
.collapsible > .block-head {
  cursor: pointer;
  margin-bottom: 0;
}
.collapsible > .block-head .chev {
  transition: transform 0.15s;
  color: var(--ink-3);
}
.collapsible.open > .block-head .chev {
  transform: rotate(90deg);
}
.collapsible > .block-body {
  display: none;
  padding-top: 12px;
}
.collapsible.open > .block-body {
  display: block;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.media-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
}
.media-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
  color: var(--ink-3);
}
.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.effects {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.effect {
  height: 36px;
  min-width: 42px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.effect.none {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 550;
}
.effect:hover {
  border-color: var(--ink-3);
}
.effect.on {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  background: var(--blue-soft);
}

/* --- кнопки сообщения */
.kb-editor {
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface-2);
  padding: 10px;
}
.kb-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kb-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  padding: 4px;
  border-radius: 10px;
  border: 1px dashed transparent;
}
.kb-row.drop {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.kb-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 550;
  font-size: 13.5px;
  position: relative;
  user-select: none;
}
.kb-btn .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-btn.primary {
  background: #3e88f7;
  border-color: #3e88f7;
  color: #fff;
}
.kb-btn.success {
  background: #31b45e;
  border-color: #31b45e;
  color: #fff;
}
.kb-btn.danger {
  background: #e5534b;
  border-color: #e5534b;
  color: #fff;
}
.kb-btn.sel {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.kb-btn.err::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}
.kb-btn .act {
  opacity: 0.75;
  flex: none;
}
.kb-btn .ce,
.kb-btn .ce img {
  width: 18px;
  height: 18px;
}
.kb-add {
  flex: 0 0 40px;
  border-radius: 10px;
  border: 1px dashed var(--ink-3);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.kb-add:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.kb-add-row {
  margin-top: 6px;
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px dashed var(--ink-3);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 550;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.kb-add-row:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.inspector {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  padding: 14px;
}
.inspector .grid-2 {
  margin-top: 10px;
}
.swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 550;
  font-size: 13px;
}
.swatch i {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.swatch.primary i {
  background: #3e88f7;
  border-color: #3e88f7;
}
.swatch.success i {
  background: #31b45e;
  border-color: #31b45e;
}
.swatch.danger i {
  background: #e5534b;
  border-color: #e5534b;
}
.swatch.on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.icon-pick {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-m);
  border: 1px dashed var(--ink-3);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-3);
}
.icon-pick.set {
  border-style: solid;
  border-color: var(--line);
}
.icon-pick .ce,
.icon-pick .ce img {
  width: 22px;
  height: 22px;
}
.issues-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.issue-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 13px;
}
.issue-row:hover {
  background: var(--surface-3);
}
.issue-row .icon {
  margin-top: 1px;
}
.issue-row.error .icon {
  color: var(--red);
}
.issue-row.warning .icon {
  color: var(--amber);
}

/* ------------------------------------------------------------------ rich editor */
.rte {
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.rte:focus-within {
  border-color: var(--blue);
  box-shadow: var(--focus);
}
.rte-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.rte-bar button {
  width: 32px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.rte-bar button:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.rte-bar button.txt {
  width: auto;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  gap: 5px;
}
.rte-bar .sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
}
.rte-area {
  min-height: 132px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 14px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.rte.compact .rte-area {
  min-height: 70px;
}
.rte-area:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-3);
  pointer-events: none;
}
.rte-area .sp,
.rte-area tg-spoiler {
  background: repeating-linear-gradient(-45deg, rgba(135, 144, 154, 0.35) 0 3px, rgba(135, 144, 154, 0.15) 3px 6px);
  border-radius: 3px;
}
.rte-area code {
  background: var(--surface-3);
  padding: 1px 4px;
  border-radius: 4px;
}
.rte-area pre {
  background: var(--surface-3);
  padding: 8px 10px;
  border-radius: 8px;
  margin: 4px 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 13px;
}
.rte-area blockquote {
  margin: 4px 0;
  padding: 2px 10px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  border-radius: 0 6px 6px 0;
}
.rte-area blockquote[data-expandable]::after {
  content: " ⌄ сворачиваемая";
  color: var(--ink-3);
  font-size: 11px;
}
.rte-area a {
  color: var(--blue);
  text-decoration: underline;
}
.rte-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 8px;
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px solid var(--line-2);
}
.rte-foot > span:last-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rte-foot .over {
  color: var(--red);
  font-weight: 600;
}
.ce {
  display: inline-flex;
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.28em;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ce img,
.ce video,
.ce svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
textarea.md-area {
  font-family: var(--mono);
  font-size: 13px;
  min-height: 200px;
}

/* --- выбор эмодзи */
.picker {
  width: min(380px, calc(100vw - 20px));
  max-height: min(430px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
}
.picker-head {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line-2);
}
.picker-grid {
  padding: 8px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
}
.picker-grid button {
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  display: grid;
  place-items: center;
  padding: 3px;
}
.picker-grid button:hover {
  background: var(--surface-3);
}
.picker-grid .ce {
  width: 28px;
  height: 28px;
}
.picker-group {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 8px 4px 2px;
}
.picker-empty {
  padding: 18px;
  color: var(--ink-2);
  font-size: 13px;
}

/* --- медиатека */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.media-card {
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.media-card:hover {
  border-color: var(--ink-3);
}
.media-card.on {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.media-card .thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--ink-3);
  overflow: hidden;
}
.media-card .thumb img,
.media-card .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-card .meta {
  padding: 7px 9px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.media-card .meta span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dropzone {
  border: 1.5px dashed var(--ink-3);
  border-radius: var(--r-l);
  padding: 26px;
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
}
.dropzone.over {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.emoji-sets {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}
.emoji-cell {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: var(--surface);
  position: relative;
}
.emoji-cell:hover {
  border-color: var(--ink-3);
}
.emoji-cell .ce {
  width: 36px;
  height: 36px;
}
.emoji-cell small {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--mono);
}
.emoji-cell .del {
  position: absolute;
  top: 2px;
  right: 2px;
  opacity: 0;
}
.emoji-cell:hover .del {
  opacity: 1;
}

/* ------------------------------------------------------------------ телефон и Telegram */
.preview-col {
  background: var(--night);
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: var(--night-ink);
}
.preview-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.preview-bar .btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
  color: var(--night-ink);
}
.preview-bar .btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.preview-bar .label {
  color: var(--night-ink-2);
  font-size: 12.5px;
  font-weight: 550;
  margin-right: auto;
}
.preview-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}
.phone {
  --tg-bg: #0e1621;
  --tg-head: #17212b;
  --tg-bubble: #182533;
  --tg-bubble-out: #2b5278;
  --tg-text: #f5f6f7;
  --tg-meta: #6d8193;
  --tg-link: #6ab2f2;
  --tg-btn: rgba(29, 41, 55, 0.82);
  --tg-btn-text: #fff;
  --tg-reply-bg: #17212b;
  --tg-reply-btn: #26364a;
  --tg-input: #17212b;
  --tg-quote: rgba(106, 178, 242, 0.12);
  --tg-quote-bar: #6ab2f2;
  --tg-wall-1: #0f1b28;
  --tg-wall-2: #15283a;
  --tg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140' fill='none' stroke='%23ffffff' stroke-opacity='0.055' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 30l22-9-6 24-6-8z'/%3E%3Ccircle cx='96' cy='26' r='7'/%3E%3Cpath d='M70 70c4-6 12-6 12 1 0 6-12 12-12 12s-12-6-12-12c0-7 8-7 12-1z'/%3E%3Cpath d='M112 84l3 7 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z'/%3E%3Cpath d='M22 96h16M30 88v16'/%3E%3Crect x='60' y='112' width='18' height='13' rx='3'/%3E%3Cpath d='M120 124c-6 0-8-5-4-8'/%3E%3C/svg%3E");
  width: 100%;
  max-width: 372px;
  height: 100%;
  max-height: 760px;
  min-height: 520px;
  border-radius: 38px;
  background: #05090d;
  padding: 9px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1.5px rgba(255, 255, 255, 0.08);
  font-family: var(--tg-font);
  position: relative;
}
.phone.light {
  --tg-bg: #9fb98d;
  --tg-head: #ffffff;
  --tg-bubble: #ffffff;
  --tg-bubble-out: #e1fec6;
  --tg-text: #000000;
  --tg-meta: #9aa5ad;
  --tg-link: #168acd;
  --tg-btn: rgba(54, 82, 46, 0.34);
  --tg-btn-text: #fff;
  --tg-reply-bg: #f0f2f5;
  --tg-reply-btn: #ffffff;
  --tg-input: #ffffff;
  --tg-quote: rgba(22, 138, 205, 0.1);
  --tg-quote-bar: #168acd;
  --tg-wall-1: #c4d4a0;
  --tg-wall-2: #93b98e;
  --tg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140' fill='none' stroke='%23284a22' stroke-opacity='0.13' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 30l22-9-6 24-6-8z'/%3E%3Ccircle cx='96' cy='26' r='7'/%3E%3Cpath d='M70 70c4-6 12-6 12 1 0 6-12 12-12 12s-12-6-12-12c0-7 8-7 12-1z'/%3E%3Cpath d='M112 84l3 7 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z'/%3E%3Cpath d='M22 96h16M30 88v16'/%3E%3Crect x='60' y='112' width='18' height='13' rx='3'/%3E%3Cpath d='M120 124c-6 0-8-5-4-8'/%3E%3C/svg%3E");
}
.tg {
  height: 100%;
  border-radius: 30px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--tg-bg);
  color: var(--tg-text);
  position: relative;
}
.tg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 14px 9px;
  background: var(--tg-head);
  color: var(--tg-text);
  position: relative;
  z-index: 2;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.tg-head .back {
  color: var(--tg-link);
  font-size: 15px;
}
.tg-head .who {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.2;
}
.tg-head .who b {
  display: block;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-head .who span {
  font-size: 12.5px;
  color: var(--tg-meta);
}
.tg-head .avatar {
  width: 34px;
  height: 34px;
  font-size: 14px;
}
.tg-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--tg-wall-1);
  background-image: var(--tg-pattern), radial-gradient(circle at 20% 15%, var(--tg-wall-2), transparent 60%),
    radial-gradient(circle at 85% 80%, var(--tg-wall-2), transparent 55%);
  scrollbar-width: thin;
}
.tg-day {
  align-self: center;
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  margin: 2px 0 4px;
}
.tg-msg {
  align-self: flex-start;
  max-width: 88%;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.tg-msg.wide {
  width: 88%;
}
.tg-msg.out {
  align-self: flex-end;
}
.tg-bubble {
  background: var(--tg-bubble);
  border-radius: 16px 16px 16px 5px;
  padding: 6px 9px 7px 10px;
  font-size: 15px;
  line-height: 1.36;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}
.tg-msg.out .tg-bubble {
  background: var(--tg-bubble-out);
  border-radius: 16px 16px 5px 16px;
}
.tg-bubble.media-only {
  padding: 3px;
}
.tg-time {
  float: right;
  margin: 7px -2px -5px 10px;
  font-size: 11.5px;
  color: var(--tg-meta);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}
.tg-time .fx {
  font-size: 12px;
}
.tg-media {
  margin: -3px -6px 6px -7px;
  border-radius: 13px 13px 4px 4px;
  overflow: hidden;
  position: relative;
  background: rgba(127, 127, 127, 0.18);
}
.tg-bubble.media-only .tg-media {
  margin: 0;
  border-radius: 13px;
}
.tg-media img,
.tg-media video {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}
.tg-media.ph {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  color: var(--tg-meta);
  font-size: 13px;
}
.tg-media.ph .icon {
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
}
.tg-media.spoiler img,
.tg-media.spoiler video {
  filter: blur(18px) saturate(0.6);
  transform: scale(1.1);
}
.tg-media.spoiler::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.7) 0.8px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.55;
}
.tg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 4px;
}
.tg-file .ico {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--tg-link);
  display: grid;
  place-items: center;
  color: #fff;
}
.tg-file small {
  display: block;
  color: var(--tg-meta);
  font-size: 12.5px;
}
.tg-sticker {
  width: 150px;
  height: 150px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tg-sticker img,
.tg-sticker video {
  max-width: 100%;
  max-height: 100%;
}
.tg-round {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.25);
  display: grid;
  place-items: center;
}
.tg-bubble b,
.tg-bubble strong {
  font-weight: 650;
}
.tg-bubble a,
.tg-bubble .link {
  color: var(--tg-link);
  text-decoration: none;
}
.tg-bubble code {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--tg-link);
}
.tg-bubble pre {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
}
.tg-bubble blockquote {
  margin: 3px 0;
  padding: 3px 22px 3px 9px;
  border-radius: 4px 7px 7px 4px;
  border-left: 3px solid var(--tg-quote-bar);
  background: var(--tg-quote);
  position: relative;
}
.tg-bubble blockquote.collapsed {
  max-height: 4.2em;
  overflow: hidden;
  cursor: pointer;
}
.tg-bubble blockquote.expandable::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--tg-quote-bar);
  border-bottom: 2px solid var(--tg-quote-bar);
  transform: rotate(45deg);
}
.tg-bubble blockquote.expandable:not(.collapsed)::after {
  transform: rotate(-135deg);
  bottom: 3px;
}
.pv-spoiler {
  border-radius: 4px;
  background-color: rgba(127, 127, 127, 0.3);
  color: transparent;
  background-image: radial-gradient(currentColor 0.6px, transparent 1px), radial-gradient(rgba(255, 255, 255, 0.7) 0.7px, transparent 1.1px);
  background-size: 5px 5px, 7px 7px;
  cursor: pointer;
  transition: color 0.2s;
}
.pv-spoiler.shown {
  color: inherit;
  background: none;
}
.pv-var {
  color: var(--tg-link);
  background: rgba(106, 178, 242, 0.14);
  border-radius: 4px;
  padding: 0 2px;
}
.tg-kb {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tg-kb-row {
  display: flex;
  gap: 4px;
}
.tg-kb-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  font: 500 14px/1.2 var(--tg-font);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  position: relative;
  backdrop-filter: blur(8px);
  transition: filter 0.1s, transform 0.08s;
}
.tg-kb-btn:hover {
  filter: brightness(1.12);
}
.tg-kb-btn:active {
  transform: scale(0.98);
}
.tg-kb-btn.primary {
  background: #3e88f7;
}
.tg-kb-btn.success {
  background: #31b45e;
}
.tg-kb-btn.danger {
  background: #e5534b;
}
.tg-kb-btn.disabled {
  opacity: 0.45;
  cursor: default;
}
.tg-kb-btn .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tg-kb-btn .corner {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 9px;
  height: 9px;
  opacity: 0.85;
}
.tg-kb-btn .ce {
  width: 19px;
  height: 19px;
  flex: none;
}
.tg-reply-kb {
  background: var(--tg-reply-bg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 40%;
  overflow-y: auto;
}
.tg-reply-kb .tg-kb-btn {
  background: var(--tg-reply-btn);
  color: var(--tg-text);
  backdrop-filter: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  min-height: 42px;
}
.tg-reply-kb .tg-kb-btn.primary,
.tg-reply-kb .tg-kb-btn.success,
.tg-reply-kb .tg-kb-btn.danger {
  color: #fff;
}
.tg-reply-kb .tg-kb-btn.primary {
  background: #3e88f7;
}
.tg-reply-kb .tg-kb-btn.success {
  background: #31b45e;
}
.tg-reply-kb .tg-kb-btn.danger {
  background: #e5534b;
}
.tg-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 14px;
  background: var(--tg-input);
  color: var(--tg-meta);
}
.tg-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--tg-text);
  font: 15px var(--tg-font);
  outline: none;
  padding: 6px 4px;
}
.tg-input input::placeholder {
  color: var(--tg-meta);
}
.tg-input button {
  border: 0;
  background: transparent;
  color: var(--tg-link);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 4px;
}
.tg-wait {
  align-self: center;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
}
.tg-typing {
  align-self: flex-start;
  background: var(--tg-bubble);
  border-radius: 16px;
  padding: 9px 12px;
  display: flex;
  gap: 4px;
}
.tg-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tg-meta);
  animation: typing 1s infinite ease-in-out;
}
.tg-typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.tg-typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typing {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
.tg-toast {
  position: absolute;
  top: 82px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 86%;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(20, 26, 33, 0.92);
  color: #fff;
  font-size: 13.5px;
  z-index: 5;
  animation: rise 0.15s ease-out;
  text-align: center;
}
.tg-alert-wrap {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 6;
  padding: 24px;
}
.tg-alert {
  width: 100%;
  max-width: 270px;
  border-radius: 14px;
  background: var(--tg-head);
  color: var(--tg-text);
  text-align: center;
  overflow: hidden;
}
.tg-alert p {
  margin: 0;
  padding: 18px 16px;
  font-size: 15px;
}
.tg-alert button {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(127, 127, 127, 0.25);
  background: transparent;
  color: var(--tg-link);
  font: 600 16px var(--tg-font);
  padding: 11px;
  cursor: pointer;
}
.fx-burst {
  position: absolute;
  pointer-events: none;
  font-size: 26px;
  z-index: 4;
  animation: burst 1.5s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.15) rotate(var(--rot));
  }
}
@media (prefers-reduced-motion: reduce) {
  .fx-burst {
    display: none;
  }
  .tg-typing i {
    animation: none;
  }
}

/* ------------------------------------------------------------------ stats */
.kpis {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  margin-bottom: 18px;
}
.kpi {
  flex: 1 1 150px;
  padding: 14px 18px;
  border-left: 1px solid var(--line-2);
}
.kpi:first-child {
  border-left: 0;
}
.kpi b {
  display: block;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.kpi span {
  color: var(--ink-2);
  font-size: 13px;
}
:root {
  --chart-a: #2d7be2;
  --chart-b: #22a058;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chart-a: #4b91ee;
    --chart-b: #2fa863;
  }
}
.chart-box {
  position: relative;
}
.chart {
  width: 100%;
  height: 240px;
  display: block;
  outline: none;
}
.chart:focus-visible {
  box-shadow: var(--focus);
  border-radius: 8px;
}
.chart .grid line {
  stroke: var(--line-2);
  stroke-width: 1;
}
.chart text {
  fill: var(--ink-3);
  font-size: 11px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.chart .end-label {
  fill: var(--ink-2);
  font-weight: 600;
}
.chart .series {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .series.a {
  stroke: var(--chart-a);
}
.chart .series.b {
  stroke: var(--chart-b);
}
.chart .area.a {
  fill: var(--chart-a);
  opacity: 0.1;
}
.chart .dot {
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .dot.a {
  fill: var(--chart-a);
}
.chart .dot.b {
  fill: var(--chart-b);
}
.chart .cross {
  stroke: var(--ink-3);
  stroke-width: 1;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  padding: 8px 10px;
  font-size: 12.5px;
  min-width: 140px;
  z-index: 3;
}
.chart-tip .tip-date {
  color: var(--ink-3);
  margin-bottom: 4px;
}
.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-tip .tip-row b {
  font-variant-numeric: tabular-nums;
  min-width: 26px;
}
.chart-tip .tip-row span {
  color: var(--ink-2);
}
.line-key {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  flex: none;
}
.line-key.a {
  background: var(--chart-a);
}
.line-key.b {
  background: var(--chart-b);
}
.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  color: var(--ink-2);
  align-items: center;
}
.chart-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.bar-cell {
  position: relative;
}
.bar-cell .fill {
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  border-radius: 0 4px 4px 0;
  background: var(--blue-soft);
  opacity: 0.75;
  z-index: 0;
}
.bar-cell span {
  position: relative;
  z-index: 1;
}
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.4s;
}

/* ------------------------------------------------------------------ list rows (triggers etc.) */
.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row-card {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
}
.trigger-row {
  grid-template-columns: 150px 1fr 200px auto;
}
.command-row {
  grid-template-columns: 170px 1fr 200px auto auto;
}
.channel-row {
  grid-template-columns: 1fr 1fr 1.3fr auto;
}
.var-row {
  grid-template-columns: 200px 1fr auto;
}
.btn-row-edit {
  grid-template-columns: 1fr 150px 1fr auto;
}
.user-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.kv {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr;
  gap: 6px 14px;
  font-size: 13.5px;
}
.kv dt {
  color: var(--ink-3);
}
.kv dd {
  margin: 0;
  word-break: break-word;
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.timeline div {
  display: flex;
  gap: 10px;
}
.timeline time {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .studio {
    grid-template-columns: 220px minmax(0, 1fr) 380px;
  }
}
@media (max-width: 1100px) {
  :root {
    --rail-w: 64px;
  }
  .rail a span.txt,
  .rail a .count {
    display: none;
  }
  .rail a {
    justify-content: center;
    padding: 10px 0;
  }
}
@media (max-width: 980px) {
  .studio {
    display: block;
    height: auto;
  }
  .studio-tabs {
    display: flex;
    position: sticky;
    top: var(--topbar-h);
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
  }
  .studio-tabs .seg {
    width: 100%;
  }
  .studio-tabs .seg button {
    flex: 1;
  }
  .studio > .screens-col,
  .studio > .editor-col,
  .studio > .preview-col {
    display: none;
  }
  .studio[data-pane="screens"] > .screens-col,
  .studio[data-pane="editor"] > .editor-col,
  .studio[data-pane="preview"] > .preview-col {
    display: flex;
  }
  .studio[data-pane="editor"] > .editor-col {
    display: block;
  }
  .screens-col {
    min-height: calc(100vh - var(--topbar-h) - 52px);
  }
  .preview-col {
    min-height: calc(100vh - var(--topbar-h) - 52px);
  }
  .preview-stage {
    padding: 12px;
  }
  .phone {
    height: calc(100vh - var(--topbar-h) - 130px);
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-stage {
    display: none;
  }
  .auth-form {
    border-right: 0;
  }
}
@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
    align-content: start; /* полоса разделов не растягивается на коротких страницах */
  }
  .rail {
    position: sticky;
    top: var(--topbar-h);
    height: auto;
    z-index: 35;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 6px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .rail .rail-sep {
    display: none;
  }
  .rail a {
    padding: 7px 10px;
    flex: none;
  }
  .rail a span.txt {
    display: inline;
  }
  .studio-tabs {
    top: calc(var(--topbar-h) + 47px);
  }
  .topbar {
    gap: 8px;
    padding: 0 10px;
  }
  .topbar .hide-sm {
    display: none !important;
  }
  .grid-2,
  .two-col,
  .template-list {
    grid-template-columns: 1fr;
  }
  .trigger-row,
  .command-row,
  .channel-row,
  .var-row,
  .btn-row-edit {
    grid-template-columns: 1fr;
  }
  .bot-item {
    grid-template-columns: auto 1fr auto;
  }
  .bot-item .metric.opt {
    display: none;
  }
  .main {
    padding: 16px 14px 60px;
  }
  .kpi {
    flex-basis: 45%;
  }
  .kpi:nth-child(3) {
    border-left: 0;
  }
  .modal {
    border-radius: 16px;
  }
  .preview-bar .label {
    display: none;
  }
  .preview-bar .btn:first-of-type {
    margin-left: auto;
  }
  .preview-stage {
    align-items: flex-start;
  }
  .phone {
    height: calc(100dvh - var(--topbar-h) - 200px);
    min-height: 440px;
    border-radius: 30px;
    padding: 6px;
  }
  .tg {
    border-radius: 25px;
  }
  .rte-foot .grow {
    display: none;
  }
}

/* ==========================================================================
   Схема сценария: блоки на холсте и провода между ними
   ========================================================================== */
:root {
  --wire: #a2abb4;
  --wire-entry: #5d6976;
  --grid-dot: #cdd2cc;
  --start-bg: #17212b;
  --btn-blue: #3e88f7;
  --btn-green: #31b45e;
  --btn-red: #e5534b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wire: #56626d;
    --wire-entry: #8c98a5;
    --grid-dot: #27303a;
    --start-bg: #2a3644;
  }
}

.flow {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  min-height: 420px;
}
.flow-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.flow-bar .seg {
  flex: none;
}
.flow-bar-group {
  display: inline-flex;
  gap: 4px;
}
.flow-bar .btn.on {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}
.flow-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

/* --- холст */
.flow-canvas {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  overflow: clip;
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--grid-dot) 1.1px, transparent 1.4px);
  background-size: 22px 22px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}
.flow-canvas.panning {
  cursor: grabbing;
}
.flow-canvas.connecting,
.flow-canvas.connecting * {
  cursor: crosshair !important;
}
.flow-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}
.flow-wires {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}
.wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
  cursor: pointer;
}
.wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.wire-arrow {
  fill: var(--wire);
  pointer-events: none;
}
.wire-g.entry .wire {
  stroke: var(--wire-entry);
}
.wire-g.entry .wire-arrow {
  fill: var(--wire-entry);
}
.wire-g.primary .wire {
  stroke: var(--btn-blue);
}
.wire-g.primary .wire-arrow {
  fill: var(--btn-blue);
}
.wire-g.success .wire {
  stroke: var(--btn-green);
}
.wire-g.success .wire-arrow {
  fill: var(--btn-green);
}
.wire-g.danger .wire {
  stroke: var(--btn-red);
}
.wire-g.danger .wire-arrow {
  fill: var(--btn-red);
}
.wire-g.input .wire {
  stroke: var(--green);
}
.wire-g.input .wire-arrow {
  fill: var(--green);
}
.wire-g.next .wire {
  stroke-dasharray: 6 6;
}
.wire-g:hover .wire,
.wire-g.hl .wire {
  stroke-width: 3;
}
.wire-g.sel .wire {
  stroke-width: 3.5;
  stroke: var(--ink);
}
.wire-g.sel .wire-arrow {
  fill: var(--ink);
}
.flow.has-focus .wire-g:not(.hl):not(.sel) {
  opacity: 0.4;
}
.wire.temp {
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
}
.wire-del {
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--red);
  box-shadow: var(--shadow-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  transform-origin: center;
}
.wire-del[hidden] {
  display: none;
}

/* --- блоки */
.fnode {
  position: absolute;
  left: 0;
  top: 0;
  width: 264px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(23, 32, 43, 0.05), 0 6px 18px rgba(23, 32, 43, 0.07);
  cursor: grab;
  outline: none;
}
.fnode.dragging {
  cursor: grabbing;
  box-shadow: var(--shadow-2);
  z-index: 3;
}
.fnode.sel {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 123, 226, 0.22), 0 8px 24px rgba(23, 32, 43, 0.12);
  z-index: 2;
}
.fnode:focus-visible {
  box-shadow: var(--focus);
}
.fnode.err {
  border-color: rgba(220, 74, 63, 0.6);
}
.fnode.drop {
  border-color: var(--blue);
  box-shadow: 0 0 0 5px rgba(45, 123, 226, 0.28);
}
.fnode.live {
  border-color: var(--green);
  animation: live-pulse 1.6s ease-in-out infinite;
  z-index: 2;
}
@keyframes live-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(34, 160, 88, 0.45), 0 8px 24px rgba(23, 32, 43, 0.1);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(34, 160, 88, 0.18), 0 8px 24px rgba(23, 32, 43, 0.1);
  }
}
.fnode-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 8px 12px;
}
.fnode-ic {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
}
.k-media .fnode-ic {
  background: var(--amber-soft);
  color: var(--amber);
}
.k-input .fnode-ic {
  background: var(--green-soft);
  color: var(--green);
}
.k-rich .fnode-ic {
  background: var(--surface-3);
  color: var(--ink-2);
}
.fnode-title {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fnode-tag {
  flex: none;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--start-bg);
  color: #fff;
}
.fnode-issue {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
}
.fnode-issue.warn {
  background: var(--amber);
}
.fnode-issue[hidden] {
  display: none;
}
.fnode-more {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.fnode-more:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.fnode-body {
  padding: 0 12px 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.fnode-text {
  line-height: 1.42;
  max-height: 7.2em;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fnode-text.clipped {
  -webkit-mask-image: linear-gradient(#000 68%, transparent);
  mask-image: linear-gradient(#000 68%, transparent);
}
.fnode-text.rich {
  white-space: normal;
  zoom: 0.82;
  max-height: 8.8em;
}
.fnode-text b,
.fnode-text strong {
  color: var(--ink);
}
.fnode-text .ce {
  width: 1.25em;
  height: 1.25em;
}
.fnode-text .pv-var {
  color: var(--blue);
  background: var(--blue-soft);
}
.fnode-text code,
.fnode-text pre {
  font-family: var(--mono);
  font-size: 11.5px;
  margin: 0;
}
.fnode-text blockquote {
  margin: 2px 0;
  padding-left: 8px;
  border-left: 2px solid var(--blue);
}
.fnode-text .link {
  color: var(--blue);
}
.fnode-media {
  height: 116px;
  margin-bottom: 8px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-3);
}
.fnode-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fnode-media.sticker img {
  object-fit: contain;
}
.fnode-media.spoiler img {
  filter: blur(10px);
  transform: scale(1.12);
}
.fnode-file {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  min-width: 0;
}
.fnode-file span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fnode-file.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: transparent;
}
.fnode-empty {
  color: var(--ink-3);
}
.fchips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
}
.fchip .icon {
  width: 12px;
  height: 12px;
}
.fnode-btns {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 12px 10px;
}
.fnode-kbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
}
.fbtn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 30px;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  text-align: center;
}
.fbtn.primary {
  background: var(--btn-blue);
  color: #fff;
}
.fbtn.success {
  background: var(--btn-green);
  color: #fff;
}
.fbtn.danger {
  background: var(--btn-red);
  color: #fff;
}
.fbtn.reply.plain {
  background: var(--surface);
  border: 1px solid var(--line);
}
.fbtn-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fbtn .fbtn-act {
  position: absolute;
  left: 9px;
  top: 50%;
  margin-top: -7px;
  opacity: 0.75;
}
.fbtn .ce {
  flex: none;
  width: 16px;
  height: 16px;
}
.fnode-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 28px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  cursor: pointer;
}
.fnode-add:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}
@media (hover: hover) {
  .fnode-add {
    opacity: 0;
    transition: opacity 0.12s;
  }
  .fnode:hover .fnode-add,
  .fnode.sel .fnode-add,
  .fnode:focus-within .fnode-add {
    opacity: 1;
  }
}
.fnode-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 12px 6px;
  border-top: 1px solid var(--line-2);
}
.fnode-out {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  font-size: 12px;
  color: var(--ink-3);
}
.fnode-out.input {
  color: var(--green);
}
.fnode-out code {
  color: var(--ink-2);
}
.fnode-out.set {
  color: var(--ink-2);
}
.fnode-delay {
  border: 0;
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.fnode-delay:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

/* --- кружки, от которых тянутся провода */
.fport {
  position: absolute;
  z-index: 1;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--wire);
}
.fport.in {
  left: -8px;
  top: 50%;
  margin-top: -7px;
  border-color: var(--line);
  pointer-events: none;
}
.fport.out {
  right: -19px;
  top: 50%;
  margin-top: -7px;
  cursor: crosshair;
  transition: transform 0.1s;
}
.fport.out::after {
  content: "";
  position: absolute;
  inset: -11px;
  border-radius: 50%;
}
.fport.out:hover {
  transform: scale(1.35);
  border-color: var(--blue);
}
.fport.out.linked {
  background: var(--wire);
}
.fport.out.linked.entry {
  background: var(--wire-entry);
  border-color: var(--wire-entry);
}
.fport.out.linked.primary {
  background: var(--btn-blue);
  border-color: var(--btn-blue);
}
.fport.out.linked.success,
.fport.out.linked.input {
  background: var(--btn-green);
  border-color: var(--btn-green);
}
.fport.out.linked.danger {
  background: var(--btn-red);
  border-color: var(--btn-red);
}
.fport.out.err {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 74, 63, 0.22);
}
@media (pointer: coarse) {
  .fport.out::after {
    inset: -17px;
  }
}

/* --- точки входа: старт, команды, ключевые слова */
.fnode.entry {
  width: 196px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
}
.fentry-ic {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--ink-2);
}
.fentry-txt {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.fentry-txt b,
.fentry-txt span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fentry-txt b {
  font-size: 13.5px;
}
.fentry-txt span {
  font-size: 11.5px;
  color: var(--ink-3);
}
.fnode.entry .fport.out {
  right: -8px;
}
.fnode.e-start {
  background: var(--start-bg);
  border-color: var(--start-bg);
  color: #fff;
}
.fnode.e-start .fentry-ic {
  background: var(--btn-green);
  color: #fff;
}
.fnode.e-start .fentry-txt span {
  color: rgba(255, 255, 255, 0.62);
}
.fnode.e-command .fentry-txt b {
  font-family: var(--mono);
  font-size: 13px;
}
.fnode.e-command .fentry-ic {
  background: var(--blue-soft);
  color: var(--blue);
}
.fnode.e-trigger .fentry-ic {
  background: var(--green-soft);
  color: var(--green);
}
.fnode.e-fallback {
  background: var(--surface-2);
  border-style: dashed;
  box-shadow: none;
}

/* --- масштаб, подсказка, всплывашки */
.flow-zoom {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
}
.flow-zoom button {
  height: 34px;
  min-width: 34px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.flow-zoom button:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.flow-zoom .flow-zoom-val {
  min-width: 50px;
}
.flow-hint-bar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(560px, calc(100% - 260px));
  padding: 8px 8px 8px 12px;
  border-radius: 12px;
  background: var(--start-bg);
  color: var(--night-ink);
  font-size: 12.5px;
  line-height: 1.35;
  box-shadow: var(--shadow-2);
}
.flow-hint-bar[hidden] {
  display: none;
}
.flow-hint-bar button {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.flow-hint-bar button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}
.fport.demo {
  position: static;
  flex: none;
  margin: 0;
  background: var(--btn-blue);
  border-color: var(--btn-blue);
}
.flow-anchor {
  position: fixed;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.flow-pop {
  padding: 14px;
}
.flow-pop .hint {
  margin: 0;
}
.popover .menu {
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

/* --- боковая панель: настройки блока и тест */
.flow-panel {
  display: none;
  flex: none;
  flex-direction: column;
  width: 440px;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.flow[data-panel="edit"] .flow-panel,
.flow[data-panel="test"] .flow-panel {
  display: flex;
}
.flow-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-2);
}
.flow-back {
  display: none;
}
.flow-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 60px;
}
.flow[data-panel="test"] .flow-panel-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.flow[data-panel="test"] .flow-panel-body .preview-col {
  flex: 1;
  min-height: 0;
}
.flow-panel .screen-title input {
  font-size: 18px;
}
.col-view {
  padding: 10px 12px 0;
}
.col-view .seg {
  width: 100%;
}
.col-view .seg button {
  flex: 1;
}
@media (prefers-reduced-motion: reduce) {
  .fnode.live {
    animation: none;
    box-shadow: 0 0 0 3px rgba(34, 160, 88, 0.45);
  }
  .fport.out {
    transition: none;
  }
}
@media (max-width: 1280px) {
  .flow-panel {
    width: 400px;
  }
}
@media (max-width: 1100px) {
  .flow-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    width: min(420px, 92%);
    box-shadow: var(--shadow-2);
  }
  .flow-hint-bar {
    max-width: calc(100% - 220px);
  }
}
@media (max-width: 760px) {
  .flow {
    height: calc(100vh - var(--topbar-h) - 47px);
    height: calc(100dvh - var(--topbar-h) - 47px);
    min-height: 360px;
  }
  .flow-bar {
    gap: 6px;
    padding: 6px 8px;
  }
  .flow-bar .btn.hide-sm-label {
    font-size: 0;
    gap: 0;
    width: 30px;
    padding: 0;
  }
  .flow-bar .seg button {
    padding: 5px 9px;
  }
  .flow-bar-group {
    gap: 2px;
  }
  .flow-panel {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    width: auto;
    border-left: 0;
  }
  .flow-back {
    display: inline-flex;
  }
  .flow-panel-head .seg {
    margin-left: auto;
  }
  .flow-panel-body {
    padding: 12px 14px 80px;
  }
  .flow-hint-bar {
    left: 10px;
    right: 10px;
    bottom: 56px;
    width: auto;
    max-width: none;
    transform: none;
  }
  .flow-zoom {
    left: 10px;
    bottom: 10px;
  }
}
@media (max-width: 430px) {
  .flow-bar .arrange-btn {
    display: none;
  }
}
@media (max-width: 380px) {
  .flow-bar .redo-btn {
    display: none;
  }
}

/* ==========================================================================
   Живые обновления: индикатор связи и подсветка нового
   ========================================================================== */
.live-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.live-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.live-state.off {
  color: var(--amber);
}
.live-state.off i {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
@keyframes fresh {
  from {
    background-color: var(--blue-soft);
  }
  to {
    background-color: transparent;
  }
}
.table tr.flash td {
  animation: fresh 2.6s ease-out;
}
.timeline .flash {
  animation: fresh 2.6s ease-out;
  border-radius: 6px;
}
.timeline .said b {
  font-weight: 600;
}
.timeline .said.message span {
  color: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
  .table tr.flash td,
  .timeline .flash {
    animation: none;
    background-color: var(--blue-soft);
  }
}

/* ==========================================================================
   Админ-панель владельца сайта: тёмная шапка — сразу видно, что вы в режиме управления
   ========================================================================== */
.admin-topbar {
  background: var(--night);
  border-bottom-color: var(--night-3);
  color: var(--night-ink);
}
.admin-topbar .btn.ghost {
  color: var(--night-ink);
}
.admin-topbar .btn.ghost:hover {
  background: var(--night-3);
}
.admin-topbar .brand-mark {
  color: var(--brand-yellow);
}
.admin-topbar .brand-name {
  color: var(--night-ink);
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(242, 196, 109, 0.4);
  color: #f2c46d;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar .brand {
  min-width: 0;
}
.brand-name {
  font-family: var(--brand-font);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.03em;
  color: var(--brand-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-entry .icon {
  color: var(--amber);
}
.menu-title {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px 6px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
}

/* сводка: сетка с линиями-разделителями при любом числе колонок */
.admin-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-2);
  overflow: hidden;
}
.admin-kpis .kpi {
  background: var(--surface);
  border-left: 0;
}
.kpi small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
}
.kpi.alert b {
  color: var(--red);
}
.kv-wide {
  grid-template-columns: minmax(190px, auto) 1fr;
}

/* строки-ссылки в панелях обзора и карточке пользователя */
.list-rows {
  display: flex;
  flex-direction: column;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 18px;
  border: 0;
  border-top: 1px solid var(--line-2);
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.list-row:first-child {
  border-top: 0;
}
a.list-row:hover,
button.list-row:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.list-rows.boxed {
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
}
.list-rows.boxed .list-row {
  padding: 10px 12px;
  cursor: default;
}
.empty.compact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 18px;
}
.tight-row {
  gap: 6px;
  flex-wrap: wrap;
}
.table tr.muted-row td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 280px;
}
.cred-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--r-m);
  background: var(--surface-2);
}
.cred-box > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.cred-box span {
  color: var(--ink-3);
}
.cred-box b {
  font-family: var(--mono);
  font-size: 15px;
  user-select: all;
  word-break: break-all;
}
.danger-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
}

/* объявление администратора на странице «Мои боты» */
.announce {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  background: var(--blue-soft);
  color: var(--ink);
  white-space: pre-line;
}
.announce > .icon {
  color: var(--blue);
  margin-top: 1px;
}
.announce.warning {
  background: var(--amber-soft);
}
.announce.warning > .icon {
  color: var(--amber);
}
.announce-x {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -3px -4px -3px 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.announce-x:hover {
  background: rgba(127, 127, 127, 0.16);
  color: var(--ink);
}
.owner-badge .icon {
  width: 13px;
  height: 13px;
}

@media (min-width: 1500px) {
  .admin-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .admin-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-kpis .kpi {
    padding: 12px 14px;
  }
  .table .opt-col {
    display: none;
  }
  .topbar .lbl {
    display: none;
  }
  .topbar .admin-entry {
    width: 36px;
    padding: 0;
  }
  .topbar .account-btn {
    max-width: 150px;
  }
  .kv-wide {
    grid-template-columns: minmax(120px, auto) 1fr;
  }
}
@media (max-width: 520px) {
  .admin-topbar .brand-name {
    display: none;
  }
}
.admin-shell .table td {
  vertical-align: middle;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.only-sm {
  display: none;
}
.actions-cell {
  text-align: right;
}
.actions-cell .btn + .btn {
  margin-left: 4px;
}
@media (max-width: 760px) {
  .only-sm {
    display: block;
  }
  .table .lbl {
    display: none;
  }
  .table .btn.sm:has(.lbl) {
    width: 30px;
    padding: 0;
  }
  .admin-shell .table td,
  .admin-shell .table th {
    padding-left: 9px;
    padding-right: 9px;
  }
}

/* ==========================================================================
   Реклама во всех ботах (админ-панель) и условия сайта
   ========================================================================== */
.ads-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.ads-preview {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.ads-preview > p {
  text-align: center;
  margin: 0;
}
.ads-preview-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 18px 12px;
  border-radius: var(--r-l);
  background: var(--night);
}
.ads-preview .phone {
  height: 600px;
  min-height: 0;
  max-width: 330px;
}
.ad-media {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.ad-thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-3);
}
.ad-thumb img,
.ad-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ad-media-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.estimate {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  min-height: 52px;
  justify-content: center;
}
.estimate-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.estimate-main b {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.estimate-main span {
  color: var(--ink-2);
}
.ad-quote {
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  background: var(--surface-2);
  border-radius: 0 var(--r-m) var(--r-m) 0;
  white-space: pre-line;
  max-height: 160px;
  overflow: auto;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* условия сайта: регистрация и окно в панели */
.terms {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.terms-title {
  font-weight: 600;
  font-size: 13.5px;
}
.terms-text {
  max-height: 150px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  white-space: pre-line;
}
.terms-text.full {
  max-height: 60vh;
  font-size: 14px;
  color: var(--ink);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--blue);
}
.terms-notice > .icon {
  color: var(--blue);
}

@media (max-width: 1100px) {
  .ads-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .ads-preview .phone {
    max-width: 300px;
  }
}
@media (max-width: 900px) {
  .ads-layout {
    grid-template-columns: 1fr;
  }
  .ads-preview {
    position: static;
  }
}
@media (max-width: 760px) {
  .ads-preview .phone {
    height: 520px;
    min-height: 0;
  }
  .opt-col-block {
    display: none;
  }
}

/* ==========================================================================
   Пользовательское соглашение: экран «Принять / Отклонить» при входе на сайт
   ========================================================================== */
.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}
.gate-top {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.gate-main {
  flex: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}
.gate-lead {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--r-l);
  background: var(--blue-soft);
  color: var(--ink);
}
.gate-lead > .icon {
  color: var(--blue);
  margin-top: 2px;
}
.terms-doc {
  padding: 28px 32px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
.terms-doc h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.terms-doc h1 + p {
  color: var(--ink-3);
  font-size: 13.5px;
  margin-bottom: 18px;
}
.terms-doc h2 {
  font-size: 17px;
  margin: 26px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line-2);
}
.terms-doc p {
  margin: 0 0 10px;
}
.terms-doc ul {
  margin: -2px 0 12px;
  padding-left: 22px;
}
.terms-doc li {
  margin: 3px 0;
}
.modal-body .terms-doc {
  padding: 0;
  border: 0;
  background: none;
  font-size: 14.5px;
}
.gate-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(23, 32, 43, 0.08);
}
.gate-bar-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.gate-bar-inner p {
  flex: 1;
  margin: 0;
}
.gate-actions {
  display: flex;
  gap: 10px;
  flex: none;
}
.gate-actions .btn {
  height: 42px;
  min-width: 132px;
}
.gate-declined {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 64px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.gate-declined h1 {
  font-size: 22px;
}
.gate-declined-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--red-soft);
  color: var(--red);
}
.gate-declined-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}
.gate-preview {
  position: fixed;
  inset: 0;
  z-index: 150;
  overflow-y: auto;
  background: var(--surface-2);
}
.gate-preview .gate {
  min-height: 100%;
}
.terms-editor {
  min-height: 320px;
  font-size: 13.5px;
  line-height: 1.5;
}
@media (max-width: 640px) {
  .terms-doc {
    padding: 20px 16px 14px;
    font-size: 14.5px;
  }
  .terms-doc h1 {
    font-size: 21px;
  }
  .gate-main {
    padding: 14px 12px 20px;
  }
  .gate-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .gate-actions .btn {
    flex: 1;
    min-width: 0;
  }
}

/* ------------------------------------------------------------------ безопасность аккаунта */
.strength {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.strength[data-level="0"] {
  visibility: hidden;
}
.strength i {
  flex: 0 0 30px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
}
.strength-label {
  margin-left: 6px;
}
.strength[data-level="1"] i:nth-child(-n + 1) {
  background: var(--red);
}
.strength[data-level="2"] i:nth-child(-n + 2) {
  background: var(--amber);
}
.strength[data-level="3"] i:nth-child(-n + 3),
.strength[data-level="4"] i:nth-child(-n + 4) {
  background: var(--green);
}
.strength[data-level="1"] .strength-label {
  color: var(--red);
}
.strength[data-level="4"] .strength-label {
  color: var(--green);
}
.input.otp-input {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.28em;
  text-align: center;
  max-width: 240px;
  height: 50px;
}
.input.otp-input.recovery,
.input.otp-input.any {
  font-size: 17px;
  letter-spacing: 0.08em;
}
.input.otp-input::placeholder {
  color: var(--line);
}
.modal-foot-slot {
  display: contents;
}
.sec-page {
  max-width: 760px;
}
.sec-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.sec-block-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.sec-block-head h2 {
  font-size: 16px;
  margin: 1px 0 3px;
}
.sec-block > :not(.sec-block-head) {
  margin-left: 54px;
}
.sec-block > .list-rows,
.sec-block > .sec-events {
  margin-top: 14px;
}
.sec-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-3);
}
.sec-ico .icon {
  color: var(--ink-2);
}
.sec-ico.on {
  background: var(--green-soft);
}
.sec-ico.on .icon {
  color: var(--green);
}
.sec-ico.off {
  background: var(--amber-soft);
}
.sec-ico.off .icon {
  color: var(--amber);
}
.sec-ico.bad {
  background: var(--red-soft);
}
.sec-ico.bad .icon {
  color: var(--red);
}
.sec-note {
  margin: 12px 0 0;
  color: var(--ink-2);
}
.sec-note.warn {
  color: var(--amber);
  font-weight: 550;
}
.sec-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.sec-events {
  display: flex;
  flex-direction: column;
  font-size: 13.5px;
}
.sec-events > div {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line-2);
}
.sec-events > div:first-child {
  border-top: 0;
}
.sec-events time {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sec-events .alarm > div > span {
  color: var(--red);
  font-weight: 550;
}
.codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 22px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r-m);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  user-select: all;
}
.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 550;
  cursor: pointer;
}
.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}
.qr-step {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.qr-box {
  width: 216px;
  height: 216px;
  padding: 8px;
  background: #ffffff; /* QR-код сканируется только на светлом фоне — и в тёмной теме */
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.qr-box img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.qr-step .steps {
  margin: 0;
}
.manual-key summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
}
.manual-key[open] summary {
  margin-bottom: 8px;
}
.secret-key {
  font-size: 15px;
  letter-spacing: 0.06em;
  word-break: break-all;
  user-select: all;
  padding: 4px 8px;
  border-radius: var(--r-s);
  background: var(--surface-3);
}
@media (max-width: 600px) {
  .qr-step {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }
  .qr-step > .stack {
    width: 100%;
  }
  .sec-block > :not(.sec-block-head) {
    margin-left: 0;
  }
  .sec-events > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .codes {
    gap: 8px 14px;
    padding: 14px;
    font-size: 15px;
  }
}

/* ------------------------------------------------------------------ центр безопасности (админ-панель) */
.check-list {
  margin-bottom: 26px;
}
.check-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 15px 18px;
  border-top: 1px solid var(--line-2);
}
.check-row:first-child {
  border-top: 0;
}
.check-row .sec-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
.check-text h4 {
  margin: 1px 0 3px;
  font-size: 14.5px;
}
.check-text p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
}
.check-action {
  align-self: center;
}
.sec-subhead {
  font-size: 17px;
  margin: 8px 0 12px;
}
.sec-attacks {
  margin-bottom: 26px;
  align-items: start;
}
.sec-attacks .panel-head h3 {
  margin: 0;
  font-size: 14px;
}
.built-in {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 22px;
}
.built-in > div {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.built-in .icon {
  margin-top: 2px;
  color: var(--green);
}
.built-in p {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 13.5px;
}
@media (max-width: 720px) {
  .check-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .check-action {
    grid-column: 2;
    align-self: start;
  }
  .sec-attacks,
  .built-in {
    grid-template-columns: minmax(0, 1fr);
  }
}
