/*
 * Демо CRM «Печатает…»: живая анимация интерфейса в рамке.
 * Все классы с префиксом demo-, все правила внутри .demo-root.
 * Рамка: градиент, белый экран, радиус 30.
 * Экран приложения на десктопе нарисован в размере 958x540 и масштабируется из js/demo.js.
 */

.demo-root {
  /* локальные токены: значения берём из css/tokens.css, запасные на случай отдельного подключения */
  --d-font: var(--font-text, "Manrope", system-ui, sans-serif);
  --d-ink: var(--ink, #050222);
  --d-ink-2: var(--ink-2, #424242);
  --d-ink-3: var(--ink-3, #727272);
  --d-ink-3s: #5f6368;   /* мелкий серый на подкрашенных фонах: держит контраст AA */
  --d-line: var(--line, #e5e7eb);
  --d-surface-2: var(--surface-2, #f9fafb);
  --d-surface-3: var(--surface-3, #f3f4f6);
  --d-tint: var(--tint, #edf1ff);
  --d-head: var(--table-head, #f6f8ff);
  --d-selected: var(--row-selected, #eff6ff);
  --d-dark: var(--control-dark, #1f2023);
  --d-accent: var(--accent-500, #4c66fa);
  --d-accent-soft: var(--accent-400, #7997ff);
  --d-accent-50: var(--accent-50, #edf3ff);
  --d-accent-600: var(--accent-600, #3b47f0);
  --d-link: var(--accent-link, #516cff);
  --d-gray-600: var(--gray-600, #4a5565);
  --d-lime: var(--lime-marker, #ddfa1b);
  --d-success: var(--success, #18cf7d);
  --d-success-bg: var(--success-bg, #effef7);
  --d-open: var(--status-open, #ffc89a);
  --d-open-bg: var(--status-open-bg, #fff7ef);
  --d-open-ink: var(--status-open-ink, #5f4323);
  --d-click: var(--status-click, #d09aff);
  --d-click-bg: var(--status-click-bg, #f5f0ff);
  --d-click-ink: var(--status-click-ink, #2d1a51);
  --d-sent: var(--status-sent, #9aaaff);
  --d-sent-bg: var(--status-sent-bg, #ebecfd);
  --d-sent-ink: var(--status-sent-ink, #26297a);
  --d-reply: var(--status-reply, #9affc4);
  --d-reply-bg: var(--status-reply-bg, #ebfdee);
  --d-reply-ink: var(--status-reply-ink, #267a41);
  --d-p1: var(--pastel-lavender, #eeedff);
  --d-p2: var(--pastel-pink, #fff1f8);
  --d-p3: var(--pastel-mint, #e1ffe6);
  --d-p4: var(--pastel-peach, #fff5ed);
  --d-p5: var(--pastel-sky, #edfbff);
  --d-stage: var(--gradient-stage, linear-gradient(180deg, #b8cafc, #a097f0));
  --d-r-frame: var(--radius-frame, 30px);
  --d-shadow-window: var(--shadow-window, 0 14px 40px #1c1c1c0f);
  --d-shadow-pop: var(--shadow-popover, 0 7px 16px #40548621);

  position: relative;
  display: block;
  width: 100%;
  max-width: 1140px;
  margin-inline: auto;
  /* раскладка демо зависит от его собственной ширины, а не от окна */
  container: demo / inline-size;
  font-family: var(--d-font);
  font-weight: 500;
  line-height: 1.4;
  color: var(--d-ink);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}
.demo-root *,
.demo-root *::before,
.demo-root *::after { box-sizing: border-box; }

/* после монтирования высоту задаёт содержимое, даже если страница дала корню aspect-ratio или min-height
   для заглушки. Высота готового демо: 56.15% ширины + 63px при ширине от 900px, ровно 532px уже 900px. */
.demo-root:not(:empty) {
  aspect-ratio: auto;
  height: auto;
  min-height: 0;
  padding-bottom: 0;
}

/* ---------- рамка ---------- */
/* боковое поле рамки: на полной ширине экран ровно 958px, на узких колонках поле сжимается до 4.5%,
   чтобы экран не мельчил (масштаб не ниже .9 до компактной раскладки) */
.demo-frame,
.demo-controls { --demo-side: max(4.5cqw, calc((100cqw - 960px) / 2)); }
.demo-frame {
  position: relative;
  padding: 4.4% var(--demo-side);
  border: 1px solid var(--d-line);
  border-radius: var(--d-r-frame);
  background: var(--d-stage);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.demo-screen {
  position: relative;
  aspect-ratio: 958 / 540;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--d-shadow-window);
  isolation: isolate;
}
.demo-app {
  position: absolute;
  top: 0;
  left: 0;
  width: 958px;
  height: 540px;
  display: flex;
  transform-origin: 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--d-ink);
  background: #fff;
  contain: layout paint;
}
.demo-confetti {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.demo-ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- сайдбар ---------- */
.demo-side {
  position: relative;
  flex: 0 0 168px;
  display: flex;
  flex-direction: column;
  padding: 16px 10px 14px;
  background: var(--d-surface-2);
  border-right: 1px solid var(--d-line);
}
.demo-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 700;
}
.demo-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 30px;
  height: 18px;
  flex: none;
  border-radius: 100px;
  background: var(--d-dark);
}
.demo-logo-mark i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}
.demo-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.demo-nav-ind {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  border-radius: 10px;
  background: var(--d-accent-50);
}
.demo-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--d-ink-3);
  transition: color .3s ease;
}
.demo-nav-item.is-active { color: var(--d-accent-600); }
.demo-side-foot {
  margin-top: auto;
  padding: 12px 6px 0;
  border-top: 1px solid var(--d-line);
}
.demo-side-foot-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--d-ink-3);
}
.demo-side-accs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.demo-side-accs .demo-ava { position: relative; }
.demo-ava-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--d-surface-2);
  border-radius: 50%;
  background: var(--d-success);
}
.demo-side-foot-note {
  margin-left: 2px;
  font-size: 11px;
  color: var(--d-ink-3);
}

/* ---------- верхняя строка и рабочая область ---------- */
.demo-main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.demo-top {
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--d-line);
}
.demo-top-mark { display: none; }
.demo-top-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 210px;
  height: 30px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--d-line);
  border-radius: 100px;
  background: var(--d-surface-2);
  font-size: 12px;
  color: var(--d-ink-3);
}
.demo-search .demo-ico { width: 14px; height: 14px; }
.demo-work {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}
.demo-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  background: #fff;
  visibility: hidden;
  opacity: 0;
}

/* ---------- общие детали ---------- */
.demo-h {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--d-ink-3);
}
.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.demo-pill--tg { background: var(--d-reply-bg); color: var(--d-reply-ink); font-weight: 600; }
.demo-pill--live { background: var(--d-reply-bg); color: var(--d-reply-ink); }
.demo-pill--queue { background: var(--d-surface-3); color: var(--d-gray-600); font-weight: 600; }
.demo-pill--sent { background: var(--d-sent-bg); color: var(--d-sent-ink); font-weight: 600; }
.demo-pill--ai { height: 22px; border: 1px solid var(--d-click); background: var(--d-click-bg); color: var(--d-click-ink); font-size: 12px; transform-origin: 100% 50%; }
.demo-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--d-success);
}
.demo-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
}
.demo-dot--sent { background: var(--d-sent); }
.demo-dot--reply { background: var(--d-reply); }
.demo-dot--click { background: var(--d-click); }
.demo-dot--deal { background: var(--d-success); }
.demo-ava {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--d-p1);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--d-ink-2);
}
.demo-ava--c2 { background: var(--d-p2); }
.demo-ava--c3 { background: var(--d-p3); }
.demo-ava--c4 { background: var(--d-p4); }
.demo-ava--c5 { background: var(--d-p5); }
.demo-ava--acc { width: 24px; height: 24px; background: var(--d-accent-50); color: var(--d-accent-600); font-size: 12px; }
.demo-metric {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--d-line);
  border-radius: 12px;
  white-space: nowrap;
}
.demo-metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--d-ink-3);
}
.demo-metric-num {
  min-width: 3ch;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* кнопка интерфейса, которую нажимает курсор */
.demo-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 100px;
  background: var(--d-dark);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.demo-btn .demo-ico { width: 14px; height: 14px; stroke-width: 1.8; }
.demo-msg {
  max-width: 360px;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
}
.demo-msg--out { background: var(--d-tint); border-bottom-right-radius: 5px; }
.demo-msg--in { background: var(--d-surface-3); border-bottom-left-radius: 5px; }

/* ---------- сцена 1: база ---------- */
.demo-s1-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.demo-s1-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.demo-s1-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.demo-table {
  border: 1px solid var(--d-line);
  border-radius: 14px;
  overflow: hidden;
}
.demo-tr {
  display: grid;
  grid-template-columns: 26px minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, .7fr) minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border-top: 1px solid var(--d-line);
  font-size: 14px;
}
.demo-tr--head {
  height: 38px;
  border-top: 0;
  background: var(--d-head);
  font-size: 13px;
  font-weight: 600;
}
.demo-tr--head .demo-td--name { grid-column: 1 / 3; font-weight: 600; }
.demo-td {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.demo-td--name { font-weight: 600; }
.demo-tr:not(.demo-tr--head) .demo-td--role,
.demo-tr:not(.demo-tr--head) .demo-td--exp { color: var(--d-ink-2); }
.demo-s1-more {
  margin-top: 10px;
  font-size: 12px;
  color: var(--d-ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- сцена 2: рассылка ---------- */
.demo-s2-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.demo-s2-name {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
}
/* кнопка запуска и статус «Идёт» занимают одно место: после нажатия кнопка уступает статусу */
.demo-s2-state { display: grid; justify-items: start; align-items: center; }
.demo-s2-state > * { grid-area: 1 / 1; }
.demo-s2-state .demo-pill--live { opacity: 0; transform-origin: 0 50%; }
.demo-s2-metric { width: 250px; }
.demo-s2-metric-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.demo-metric-of {
  margin-left: auto;
  font-size: 12px;
  color: var(--d-ink-3);
}
.demo-bar {
  position: relative;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 100px;
  background: var(--d-surface-3);
}
.demo-bar-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--d-accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.demo-tpl {
  margin-top: 14px;
  padding: 12px 16px 14px;
  border: 1px solid var(--d-line);
  border-radius: 16px;
}
.demo-tpl-msg {
  display: inline-block;
  max-width: 520px;
}
.demo-var {
  color: var(--d-accent-600);
  border-bottom: 1.5px dashed var(--d-accent-soft);
}
.demo-s2-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr);
  margin-top: 16px;
}
.demo-acc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.demo-acc {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid var(--d-line);
  border-radius: 12px;
  background: #fff;
}
/* доля отправленного с этого аккаунта */
.demo-acc-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 3px;
  overflow: hidden;
  border-radius: 100px;
  background: var(--d-surface-3);
}
.demo-acc-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--d-accent-soft);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.demo-acc-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.demo-online {
  width: 7px;
  height: 7px;
  flex: none;
  margin-left: auto;
  border-radius: 50%;
  background: var(--d-success);
}
.demo-s2-note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--d-ink-3);
}
.demo-rcpts {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* окно списка: края гаснут, сам список едет вверх по ходу отправки */
.demo-rcpt-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 8px, #000 calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 8px, #000 calc(100% - 40px), transparent 100%);
}
.demo-rcpt {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
}
.demo-rcpt-name { white-space: nowrap; }
.demo-rcpt .demo-ava { width: 24px; height: 24px; }
.demo-rcpt-st {
  position: relative;
  width: 100px;
  height: 22px;
  margin-left: auto;
}
.demo-rcpt-st .demo-pill {
  position: absolute;
  top: 0;
  right: 0;
  transform-origin: 100% 50%;
}
.demo-fly {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 24px;
  border-radius: 12px 12px 12px 4px;
  background: var(--d-accent);
  opacity: 0;
}
.demo-fly--ghost { z-index: 2; background: var(--d-accent-soft); }
.demo-fly i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}

/* ---------- сцена 3: ответы ---------- */
.demo-s3-metrics {
  display: flex;
  gap: 10px;
}
.demo-inbox {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--d-line);
  border-radius: 16px;
}
.demo-chats { border-right: 1px solid var(--d-line); }
.demo-chat {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  height: 62px;
  padding: 0 12px;
  border-bottom: 1px solid var(--d-line);
}
.demo-chat.is-active { background: var(--d-selected); }
.demo-chat .demo-ava { width: 32px; height: 32px; }
.demo-chat-main { min-width: 0; }
.demo-chat-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.demo-chat-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-chat-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--d-ink-3s);
  font-variant-numeric: tabular-nums;
}
.demo-chat-prev {
  position: relative;
  height: 22px;
  margin-top: 3px;
}
.demo-prev-out {
  position: absolute;
  top: 3px;
  left: 0;
  right: 26px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--d-ink-3s);
}
.demo-prev-ai { opacity: 0; }
.demo-prev-in {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  max-width: calc(100% - 26px);
  height: 22px;
  padding: 0 9px;
  border-radius: 11px 11px 11px 4px;
  background: var(--d-surface-3);
  font-size: 12px;
  white-space: nowrap;
}
.demo-badge {
  position: absolute;
  top: 2px;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 100px;
  background: var(--d-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}
.demo-thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.demo-thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--d-line);
}
.demo-thread-sub {
  font-size: 12px;
  color: var(--d-ink-3s);
}
.demo-back { display: none; color: var(--d-ink-3); }
/* тост о новом ответе: тёмная плашка внизу справа */
.demo-toast {
  position: absolute;
  right: 40px;
  bottom: 36px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 15px;
  background: #474747;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
}
.demo-msgs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
}
.demo-msgs > .demo-msg--out { align-self: flex-end; }
.demo-msgs > .demo-msg--in { align-self: flex-start; }
.demo-slot {
  position: relative;
  display: flex;
  justify-content: flex-end;
}
/* «печатает…»: белый пузырь с рамкой и тёмно-синими точками, как у логотипа */
.demo-typing {
  position: absolute;
  top: 26px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--d-line);
  border-radius: 16px 16px 5px 16px;
  background: #fff;
  box-shadow: var(--d-shadow-window);
  font-size: 13px;
  font-weight: 600;
  color: var(--d-ink-2);
}
.demo-tdots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}
.demo-tdots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--d-accent);
}
.demo-ai {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  width: 360px;
  max-width: 100%;
}

/* ---------- сцены 4 и 5: воронка и сделки ---------- */
.demo-s4-note {
  flex: none;
  margin: -4px 0 10px;
  font-size: 12px;
  color: var(--d-ink-3);
}
.demo-board {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}
.demo-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--d-line);
  border-radius: 16px;
  background: var(--d-surface-2);
}
.demo-col--1 { grid-column: 1; grid-row: 1; }
.demo-col--2 { grid-column: 2; grid-row: 1; }
.demo-col--3 { grid-column: 3; grid-row: 1; }
.demo-col--4 { grid-column: 4; grid-row: 1; }
.demo-col-head {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 4px;
}
.demo-col-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  margin-left: auto;
  padding: 0 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.demo-count--sent { background: var(--d-sent-bg); color: var(--d-sent-ink); }
.demo-count--reply { background: var(--d-reply-bg); color: var(--d-reply-ink); }
.demo-count--click { background: var(--d-click-bg); color: var(--d-click-ink); }
.demo-count--deal { background: var(--d-success-bg); color: var(--d-reply-ink); box-shadow: inset 0 0 0 1px var(--d-success); }
.demo-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.demo-card {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  height: 52px;
  padding: 0 8px;
  border: 1px solid var(--d-line);
  border-radius: 12px;
  background: #fff;
}
.demo-card > .demo-ava { width: 22px; height: 22px; font-size: 10px; }
.demo-card--slot { visibility: hidden; }
.demo-card-hl,
.demo-card-sh {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}
.demo-card-hl { border: 1px solid var(--d-success); background: var(--d-success-bg); }
.demo-card-sh { box-shadow: var(--d-shadow-pop); }
.demo-card > .demo-ava,
.demo-card-txt { position: relative; }
.demo-card-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.demo-card-name,
.demo-card-role {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.demo-card-name { font-size: 13px; font-weight: 700; line-height: 17px; }
.demo-card-role { font-size: 11px; line-height: 15px; color: var(--d-ink-3s); }
.demo-skel {
  display: block;
  height: 8px;
  border-radius: 6px;
  background: var(--d-line);
}
.demo-card--skel .demo-ava { background: var(--d-surface-3); }
.demo-card--skel .demo-skel + .demo-skel { width: 60%; margin-top: 6px; background: var(--d-surface-3); }
.demo-veil {
  grid-column: 1 / 4;
  grid-row: 1;
  z-index: 3;
  border-radius: 16px;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.demo-plate-wrap {
  grid-column: 1 / 4;
  grid-row: 1;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.demo-plate {
  min-width: 300px;
  padding: 22px 34px 24px;
  border: 1px solid var(--d-line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--d-shadow-pop);
  text-align: center;
  opacity: 0;
}
.demo-plate-deals {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--d-success);
  color: #fff;
}
.demo-check .demo-ico { width: 14px; height: 14px; stroke-width: 2.2; }
.demo-sum {
  position: relative;
  display: block;
  width: fit-content;
  margin: 10px auto 0;
  padding: 0 12px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.demo-sum-mark {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--d-lime);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.demo-sum-num {
  position: relative;
  display: inline-block;
  min-width: 5.3em;
  text-align: center;
}
.demo-plate-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--d-ink-3);
}

/* курсор: отдельный элемент поверх экрана, кончик стрелки в точке (2, 2) */
.demo-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  width: 20px;
  height: 24px;
  margin: -2px 0 0 -2px;
  transform-origin: 2px 2px;
  opacity: 0;
  pointer-events: none;
}
.demo-cursor svg { display: block; width: 20px; height: 24px; }

/* пометка «Пауза» в углу рамки, пока демо стоит по наведению, фокусу или кнопке */
.demo-hold {
  position: absolute;
  top: calc(2.2cqw - 12px);
  right: var(--demo-side);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px 0 8px;
  border: 1px solid rgb(255 255 255 / .7);
  border-radius: 100px;
  background: rgb(255 255 255 / .72);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--d-ink);
  opacity: 0;
  transition: opacity .15s ease-in-out;
  pointer-events: none;
}
.demo-hold .demo-ico { width: 12px; height: 12px; stroke-width: 2.2; }
.demo-root[data-demo-hold] .demo-hold { opacity: 1; }

/* ---------- шаги и пауза под рамкой ---------- */
.demo-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  padding-inline: var(--demo-side);
}
.demo-steps {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.demo-pause {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--d-line);
  border-radius: 50%;
  background: #fff;
  color: var(--d-ink-2);
  cursor: pointer;
  transition: color .15s ease-in-out, border-color .15s ease-in-out;
}
/* зона касания 44px */
.demo-pause::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; }
.demo-pause .demo-ico { width: 14px; height: 14px; stroke-width: 2; }
.demo-pause .demo-ico--play { display: none; fill: currentColor; stroke-width: 1.4; }
.demo-pause[aria-pressed="true"] .demo-ico--pause { display: none; }
.demo-pause[aria-pressed="true"] .demo-ico--play { display: block; }
.demo-pause:hover { color: var(--d-accent-600); border-color: var(--d-accent-soft); }
.demo-pause:focus { outline: none; }
.demo-pause:focus-visible { outline: 2px solid var(--d-accent-600); outline-offset: 3px; }
.demo-root[data-demo-state="static"] .demo-pause { display: none; }
.demo-step {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  margin: 0;
  padding: 8px 0 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  color: var(--d-ink-3);
  cursor: pointer;
  transition: color .15s ease-in-out;
}
.demo-step:hover { color: var(--d-accent-600); }
.demo-step.is-active { color: var(--d-ink); }
.demo-step:focus { outline: none; }
.demo-step:focus-visible { outline: 2px solid var(--d-accent-600); outline-offset: 3px; }
.demo-step-bar {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 100px;
  background: var(--d-line);
}
.demo-step-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--d-accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ---------- компактная версия: телефоны и любые колонки уже 950px ---------- */
/* при ширине окна до 768 (контейнер 738 с полями 15) это и есть мобильная версия */
@container demo (width < 950px) {
  .demo-frame { padding: 18px 12px; border-radius: 24px; }
  .demo-screen { aspect-ratio: auto; height: 452px; border-radius: 14px; }
  .demo-app { right: 0; bottom: 0; width: auto; height: auto; }
  .demo-side { display: none; }
  .demo-top { flex-basis: 44px; gap: 8px; padding: 0 14px; }
  .demo-top-mark { display: inline-flex; width: 26px; height: 16px; }
  .demo-top-title { font-size: 14px; }
  .demo-search { display: none; }
  .demo-scene { padding: 12px; }
  .demo-h { font-size: 13px; white-space: normal; }
  .demo-metric { height: 30px; gap: 6px; padding: 0 10px; border-radius: 10px; }
  .demo-metric-num { font-size: 16px; }
  .demo-btn { height: 30px; gap: 6px; padding: 0 11px; }
  .demo-btn .demo-ico { width: 13px; height: 13px; }
  .demo-hold { top: 29px; right: 22px; }

  /* 1: заголовок и кнопка сверху, счётчик под ними; строки таблицы в две строки, Telegram скрыт */
  .demo-s1-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "t b" "m m";
    align-items: center;
    gap: 8px 10px;
    margin-bottom: 10px;
  }
  .demo-s1-title,
  .demo-s1-actions { display: contents; }
  .demo-s1-title .demo-h { grid-area: t; }
  .demo-s1-actions .demo-metric { grid-area: m; justify-self: start; }
  .demo-s1-actions .demo-btn { grid-area: b; justify-self: end; }
  .demo-table { border-radius: 12px; }
  .demo-tr--head { display: none; }
  .demo-tr {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas: "a n e" "a r e";
    align-content: center;
    column-gap: 10px;
    height: 42px;
    padding: 0 12px;
    font-size: 13px;
  }
  .demo-tr--head + .demo-tr { border-top: 0; }
  .demo-tr > .demo-ava { grid-area: a; width: 28px; height: 28px; }
  .demo-tr .demo-td--name { grid-area: n; font-size: 13px; line-height: 17px; }
  .demo-tr .demo-td--role { grid-area: r; font-size: 12px; line-height: 15px; }
  .demo-tr:not(.demo-tr--head) .demo-td--role { color: var(--d-ink-3); }
  .demo-tr .demo-td--exp { grid-area: e; font-size: 12px; }
  .demo-tr .demo-td--tg { display: none; }
  .demo-s1-more { margin-top: 8px; }

  /* 2: аккаунты в ряд, под ними короткий список получателей, пузырьки летят сверху вниз */
  .demo-s2-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .demo-s2-name { flex-wrap: wrap; height: auto; min-height: 30px; gap: 8px; }
  .demo-s2-metric { width: auto; }
  .demo-tpl { margin-top: 12px; padding: 10px 12px 12px; border-radius: 12px; }
  .demo-tpl-msg { display: block; max-width: none; }
  .demo-s2-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
  .demo-accs > .demo-label { display: none; }
  .demo-acc-list { flex-direction: row; gap: 6px; }
  .demo-acc { flex: 1 1 0; min-width: 0; justify-content: center; gap: 6px; height: 36px; padding: 0 6px; border-radius: 10px; }
  .demo-acc .demo-ava { display: none; }
  .demo-acc-name { font-size: 12px; }
  .demo-online { margin-left: 0; }
  .demo-acc-bar { left: 8px; right: 8px; bottom: 4px; height: 2px; }
  .demo-s2-note { display: none; }
  .demo-rcpts { flex: 1 1 auto; }
  .demo-rcpts > .demo-label { margin-bottom: 4px; }
  .demo-rcpt { height: 32px; font-size: 12px; }
  .demo-rcpt .demo-ava { width: 22px; height: 22px; font-size: 10px; }
  .demo-rcpt-st { width: 92px; }
  .demo-fly { width: 30px; height: 20px; border-radius: 10px 10px 10px 4px; gap: 3px; }
  .demo-fly i { width: 3px; height: 3px; }

  /* 3: открытый чат без шаблона, в списке только два новых ответа; шапка чата читается как открытый диалог */
  .demo-s3-metrics .demo-metric { flex: 1 1 0; min-width: 0; }
  .demo-inbox { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); margin-top: 10px; border-radius: 12px; }
  .demo-chats { border-right: 0; border-bottom: 1px solid var(--d-line); }
  .demo-chat { height: 50px; padding: 0 10px; }
  .demo-chat:nth-child(n + 3) { display: none; }
  .demo-chat:nth-child(2) { border-bottom: 0; }
  .demo-chat .demo-ava { width: 28px; height: 28px; }
  .demo-chat-prev { margin-top: 2px; }
  .demo-thread { min-height: 0; overflow: hidden; }
  .demo-thread-head { flex: none; height: 42px; padding: 0 12px 0 6px; gap: 6px; background: var(--d-surface-2); }
  .demo-thread-head .demo-ava { width: 26px; height: 26px; }
  .demo-back { display: inline-flex; }
  /* сообщения прижаты к низу, как в мессенджере: лишнее уходит под шапку чата */
  .demo-msgs { flex: 1 1 auto; min-height: 0; justify-content: flex-end; gap: 8px; padding: 10px 12px; overflow: hidden; }
  .demo-msgs > .demo-msg--out:first-child { display: none; }
  .demo-ai { width: 94%; }
  .demo-toast { display: none; }

  /* 4 и 5: колонки канбана становятся строками, карточки становятся аватарами, плашка встаёт под воронку */
  .demo-s4-note { margin: 0 0 4px; }
  .demo-board { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(4, auto) minmax(0, 1fr); gap: 6px; }
  .demo-col--1 { grid-column: 1; grid-row: 1; }
  .demo-col--2 { grid-column: 1; grid-row: 2; }
  .demo-col--3 { grid-column: 1; grid-row: 3; }
  .demo-col--4 { grid-column: 1; grid-row: 4; }
  .demo-col { gap: 4px; padding: 5px 10px; border-radius: 12px; }
  .demo-col-head { height: 18px; padding: 0; }
  .demo-count { min-width: 32px; height: 18px; }
  .demo-cards { flex-direction: row; gap: 6px; }
  .demo-card { display: block; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
  .demo-card > .demo-ava { width: 26px; height: 26px; font-size: 11px; }
  .demo-card-txt,
  .demo-card--skel { display: none; }
  .demo-card-hl { inset: -3px; border-width: 2px; border-radius: 50%; }
  .demo-card-sh { border-radius: 50%; }
  .demo-veil { grid-column: 1; grid-row: 1 / 4; border-radius: 12px; }
  .demo-plate-wrap { grid-column: 1; grid-row: 5; }
  .demo-plate { min-width: 72%; padding: 10px 14px 12px; border-radius: 16px; }
  .demo-plate-deals { font-size: 13px; gap: 6px; }
  .demo-check { width: 18px; height: 18px; }
  .demo-check .demo-ico { width: 12px; height: 12px; }
  .demo-sum { margin-top: 4px; padding: 0 8px; font-size: 26px; }
  .demo-sum-mark { border-radius: 10px; }
  .demo-plate-note { margin-top: 2px; font-size: 12px; }

  .demo-controls { gap: 8px; margin-top: 12px; padding-inline: 0; }
  .demo-steps { grid-template-columns: repeat(5, minmax(min-content, 1fr)); gap: 8px; }
  /* кнопка шага не ниже 44px */
  .demo-step { gap: 7px; padding: 12px 0 10px; font-size: 12px; }
  .demo-pause { width: 36px; height: 36px; }
  .demo-pause::before { inset: -4px; }
}

/* совсем узкие: подписи шагов помещаются на 320 */
@container demo (width < 360px) {
  .demo-steps { gap: 6px; }
  .demo-step { font-size: 11px; }
  .demo-controls { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-nav-item,
  .demo-step,
  .demo-pause,
  .demo-hold { transition: none; }
}
