/*
  Дизайн-система Агентов Нейроактив:
  - Дневная тема: тёплая песочно-кремовая палитра Base44 (#F8F6F1, белый карточный фон, терракотовый оранжевый #FF6B35).
  - Ночная тема: глубокий тёплый графит Synoda AI (#141312, тёмный графитовый карточный фон #1E1C1A, тёплый янтарный #E06D3B).
*/
:root,
[data-theme="light"] {
  --bg: #f8f6f1;
  --surface: #ffffff;
  --surface-alt: #f1ede4;
  --section: #ffffff;
  --text: #191715;
  --text-secondary: #57524d;
  --hint: #78736b;
  --link: #ff6b35;
  --accent: #ff6b35;
  --accent-hover: #fa5a1e;
  --accent-text: #ffffff;
  --danger: #d6453d;
  --line: rgba(22, 21, 20, 0.08);
  --line-strong: rgba(22, 21, 20, 0.16);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --card-shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.07);
  --crown: #f0743a;
  --badge-bg: rgba(255, 107, 53, 0.1);
  --badge-text: #e0551e;
  --icon-bg: #f3efe7;

  --done: #2f9e5b;
  --stale: #d48a1a;

  --radius-card: 16px;
  --radius-row: 14px;
  --radius-control: 12px;
  --gutter: 16px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312;
    --surface: #1e1c1a;
    --surface-alt: #272421;
    --section: #1e1c1a;
    --text: #f0ede8;
    --text-secondary: #b5afa7;
    --hint: #8c867e;
    --link: #e06d3b;
    --accent: #e06d3b;
    --accent-hover: #ec7846;
    --accent-text: #ffffff;
    --danger: #e0534b;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --card-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    --card-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
    --crown: #ff8c42;
    --badge-bg: rgba(224, 109, 59, 0.16);
    --badge-text: #ff975e;
    --icon-bg: #272421;

    --done: #34b368;
    --stale: #e69824;

    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg: #141312;
  --surface: #1e1c1a;
  --surface-alt: #272421;
  --section: #1e1c1a;
  --text: #f0ede8;
  --text-secondary: #b5afa7;
  --hint: #8c867e;
  --link: #e06d3b;
  --accent: #e06d3b;
  --accent-hover: #ec7846;
  --accent-text: #ffffff;
  --danger: #e0534b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --card-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  --card-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
  --crown: #ff8c42;
  --badge-bg: rgba(224, 109, 59, 0.16);
  --badge-text: #ff975e;
  --icon-bg: #272421;

  --done: #34b368;
  --stale: #e69824;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px var(--gutter) 48px;
}

a {
  color: var(--link);
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.state {
  color: var(--hint);
  text-align: center;
  padding: 48px 8px;
}

.state.error {
  color: var(--danger);
}

/* Заголовок экрана */
.top {
  padding: 4px 0 16px;
}

.top h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

.top .sub {
  color: var(--hint);
  margin: 6px 0 0;
  font-size: 14px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--hint);
  margin: 24px 4px 8px;
}

/* Списки в стиле Telegram: строки внутри карточки */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.list > li + li {
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: var(--text);
  min-height: 54px;
  text-decoration: none;
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  a.row:hover {
    background: var(--surface-alt);
  }
}

a.row:active {
  background: var(--surface-alt);
}

.row .icon {
  font-size: 20px;
  width: 26px;
  text-align: center;
  flex: none;
}

.row .body {
  flex: 1;
  min-width: 0;
}

.row .title {
  display: block;
  font-weight: 600;
  font-size: 15px;
}

.row .meta {
  display: block;
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
}

.row .end {
  color: var(--hint);
  font-size: 13px;
  flex: none;
}

.row-chevron {
  color: var(--hint);
  font-size: 19px;
  line-height: 1;
  flex: none;
  padding-left: 2px;
}

.row.muted .title {
  color: var(--hint);
}

/* Статус агента: цветная точка */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  background: var(--line-strong);
}

.dot.in_progress {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--badge-bg);
}

.dot.done {
  background: var(--done);
}

.dot.stale {
  background: var(--stale);
}

/* Быстрые переходы на главном экране — интерактивные карточки с объёмом */
.shortcuts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 24px;
}

.shortcut-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  color: var(--text);
  box-shadow: var(--card-shadow);
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.12s ease;
  position: relative;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.shortcut-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--icon-bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: none;
}

.shortcut-content {
  flex: 1;
  min-width: 0;
}

.shortcut-card .title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.shortcut-card .meta {
  display: block;
  font-size: 13px;
  color: var(--hint);
  line-height: 1.3;
}

.shortcut-chevron {
  font-size: 20px;
  line-height: 1;
  color: var(--hint);
  padding-left: 4px;
  flex: none;
}

.shortcut-card:active {
  transform: scale(0.985);
  background: var(--surface-alt);
}

@media (hover: hover) and (pointer: fine) {
  .shortcut-card:hover {
    border-color: var(--accent);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
  }
}

/* Документ: раздел паспорта и ответ агента. Главное на экране — сам текст */
.doc {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 18px 18px 8px;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.doc > :first-child {
  margin-top: 0;
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  margin: 1.4em 0 0.5em;
}

.doc h1 {
  font-size: 20px;
}

.doc p,
.doc ul,
.doc ol,
.doc blockquote {
  margin: 0 0 0.9em;
}

.doc ul,
.doc ol {
  padding-left: 1.3em;
}

.doc li + li {
  margin-top: 0.25em;
}

.doc blockquote {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 12px;
  color: var(--text);
}

.doc hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4em 0;
}

.doc code {
  background: var(--surface);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.92em;
}

.doc pre {
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 12px;
  overflow-x: auto;
}

.doc pre code {
  background: none;
  padding: 0;
}

/* ==========================================
   Красивые адаптивные таблицы и карточки (Spreadsheet Mobile & Cards)
   ========================================== */

.table-container {
  margin: 14px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.table-view-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.table-view-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.table-view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.table-view-btn:active {
  transform: scale(0.96);
}

.table-scroll-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--surface-alt);
}

.doc .table,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 115px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  max-width: 100%;
}

.doc table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 12.5px;
  line-height: 1.35;
}

.doc th,
.doc td {
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.doc th:last-child,
.doc td:last-child {
  border-right: none;
}

.doc tr:last-child td {
  border-bottom: none;
}

.doc th,
.lib-body th,
.table-wrap th {
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
  white-space: normal;
  word-break: normal;
  line-height: 1.25;
  border-bottom: 2px solid var(--line-strong);
  padding: 8px 6px;
}

/* Компактная первая зафиксированная колонка (Sticky Column 1) */
.doc th:first-child,
.doc td:first-child,
.table-wrap th:first-child,
.table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 115px;
  min-width: 110px;
  max-width: 120px;
  background: var(--surface);
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 600;
  padding: 8px 8px;
  border-right: 2px solid var(--line-strong);
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.12);
  word-break: break-word;
  hyphens: auto;
}

.doc th:first-child,
.table-wrap th:first-child {
  background: var(--surface-alt);
  z-index: 3;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
}

/* Чередование строк (зебра) для удобного чтения */
.doc tbody tr:nth-child(even) td:not(:first-child),
.table-wrap tbody tr:nth-child(even) td:not(:first-child) {
  background: color-mix(in srgb, var(--surface-alt) 35%, var(--surface));
}

.doc tbody tr:nth-child(even) td:first-child,
.table-wrap tbody tr:nth-child(even) td:first-child {
  background: color-mix(in srgb, var(--surface-alt) 20%, var(--surface));
}

/* Усиленная граница закреплённой колонки при скролле */
.table-wrap.has-scrolled th:first-child,
.table-wrap.has-scrolled td:first-child {
  background: var(--surface) !important;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.22);
  border-right: 2px solid var(--accent);
}

.table-wrap th .col-sub {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--hint);
  margin-top: 2px;
}

/* ============================================================
   А. Числовая матрица (Скоринг сегментов ЦА)
   ============================================================ */
.table-wrap.table-type-scoring th:not(:first-child),
.table-wrap.table-type-scoring td:not(:first-child) {
  text-align: center;
  width: 105px;
  min-width: 95px;
  max-width: 115px;
  padding: 8px 6px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scroll-margin-left: 125px;
  transition: background 0.15s ease, color 0.15s ease;
}

.table-wrap.table-type-scoring th:not(:first-child) {
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.table-wrap.table-type-scoring td:not(:first-child):not(:last-child) {
  font-weight: 700;
  font-size: 14px;
}

.table-wrap.table-type-scoring th:last-child {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface-alt));
  color: var(--accent);
  font-weight: 800;
  width: 105px;
  min-width: 95px;
}

.table-wrap.table-type-scoring td:last-child {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.table-wrap.table-type-scoring th.col-active,
.table-wrap.table-type-scoring td.col-active {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)) !important;
}

.table-wrap.table-type-scoring th.col-active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-alt)) !important;
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

/* ============================================================
   Б. Текстовые таблицы (Сценарии Reels, раскадровка, процессы)
   ============================================================ */
.table-wrap.table-type-text {
  scroll-padding-left: 120px;
}

.table-wrap.table-type-text table {
  width: max-content;
  min-width: 100%;
}

.table-wrap.table-type-text th:first-child,
.table-wrap.table-type-text td:first-child {
  width: 120px;
  min-width: 110px;
  max-width: 130px;
  background: var(--surface) !important;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.12);
  border-right: 2px solid var(--line-strong);
}

.table-wrap.table-type-text th:not(:first-child),
.table-wrap.table-type-text td:not(:first-child) {
  text-align: left;
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  min-width: 180px;
  max-width: 320px;
  padding: 10px 12px;
  scroll-snap-align: start;
  scroll-margin-left: 130px;
  transition: background 0.15s ease, color 0.15s ease;
}

.table-wrap.table-type-text th:not(:first-child) {
  font-weight: 700;
  font-size: 11.5px;
  background: var(--surface-alt);
  color: var(--text);
  line-height: 1.3;
}

/* Последняя колонка (например, речь спикера) */
.table-wrap.table-type-text td:last-child {
  min-width: 270px;
  max-width: 380px;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
}

.table-wrap.table-type-text th:last-child {
  min-width: 270px;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
}

/* Подсветка активной колонки для текстовой таблицы */
.table-wrap.table-type-text th.col-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-alt)) !important;
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.table-wrap.table-type-text td.col-active {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface)) !important;
}

.table-wrap.table-type-text tbody tr:nth-child(even) td:not(:first-child) {
  background: color-mix(in srgb, var(--surface-alt) 35%, var(--surface));
}

.table-wrap.table-type-text tbody tr:nth-child(even) td.col-active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface)) !important;
}

/* Общий фоллбэк для остальных таблиц без явного класса */
.table-wrap:not(.table-type-text):not(.table-type-scoring) th:not(:first-child),
.table-wrap:not(.table-type-text):not(.table-type-scoring) td:not(:first-child) {
  text-align: left;
  min-width: 140px;
  max-width: 280px;
  padding: 9px 10px;
}

/* Режим вертикальных карточек (Карточки сегментов) */
.table-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.segment-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease;
}

.segment-card.is-leader {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 15%, transparent);
}

.segment-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.segment-card-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  flex: 1;
}

.segment-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.segment-card-badge small {
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.75;
}

.segment-card-leader-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
  align-self: flex-start;
  margin-top: -4px;
  margin-bottom: 2px;
}

.segment-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.crit-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface-alt);
  padding: 7px 9px;
  border-radius: 8px;
}

.crit-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--hint);
  line-height: 1.2;
}

.crit-value-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.crit-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 14px;
}

.crit-progress {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.crit-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ============================================================
   В. Съёмочные карточки для текстовых таблиц (Script Cards View)
   ============================================================ */
.script-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease;
}

.script-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.script-card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}

/* Блок речи спикера (акцентный фокус карточки) */
.script-speech-box {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-alt));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.script-speech-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.script-speech-icon {
  font-size: 13.5px;
}

.script-speech-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.script-speech-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

/* Сетка режиссёрских заметок (визуал, экранная плашка и т.д.) */
.script-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 380px) {
  .script-meta-grid {
    grid-template-columns: 1fr;
  }
}

.script-meta-item {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.script-meta-item.is-screen-text {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-alt));
  border-color: color-mix(in srgb, var(--accent) 20%, var(--line));
}

.script-meta-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--hint);
  line-height: 1.2;
}

.script-meta-content {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  font-weight: 600;
  word-break: normal;
  overflow-wrap: break-word;
}

.script-meta-item.is-screen-text .script-meta-content {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 2px 10px;
  color: var(--hint);
  font-size: 14px;
}

/* Диалог */
.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg.user {
  align-self: flex-end;
  max-width: 88%;
  background: color-mix(in srgb, var(--accent) 16%, var(--section));
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
}

.msg.user p {
  margin: 0;
}

.msg.user p + p {
  margin-top: 0.6em;
}

.msg.assistant .doc {
  border-radius: 4px 16px 16px 16px;
}

.msg-foot {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--hint);
  font-size: 13px;
  margin: 6px 4px 0;
}

.msg.user .msg-foot {
  justify-content: flex-end;
  margin: 4px 0 0;
}

.msg.target .doc {
  box-shadow: 0 0 0 2px var(--accent);
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
.nav-tab:focus:not(:focus-visible),
.lib-tab:focus:not(:focus-visible),
.shortcut-card:focus:not(:focus-visible) {
  outline: none !important;
}

/* ==========================================
   Apple Fluid Micro-Interactions & Spring Physics
   ========================================== */

button,
.button,
.btn-secondary,
.shortcut-card,
.nav-tab,
.lib-tab,
.model-card-item,
.segmented-btn,
.period-btn,
.preset-btn,
.icon-round-btn,
.model-pill-btn,
.credits-meter,
a.row {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.2s ease,
              background-color 0.15s ease,
              border-color 0.15s ease,
              box-shadow 0.2s ease;
}

button:active,
.button:active,
.btn-secondary:active,
.shortcut-card:active,
.nav-tab:active,
.lib-tab:active,
.model-card-item:active,
.segmented-btn:active,
.period-btn:active,
.preset-btn:active,
.icon-round-btn:active,
.model-pill-btn:active,
.credits-meter:active,
a.row:active {
  transform: scale(0.955) !important;
  opacity: 0.82 !important;
  transition: transform 60ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 60ms ease-out !important;
}

/* Элементы управления */
button,
.button {
  font: inherit;
  border: 0;
  border-radius: var(--radius-control);
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:active,
.button:active {
  transform: scale(0.97);
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--card-shadow);
}

button.secondary:active {
  background: var(--surface-alt);
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  button.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

button.danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  box-shadow: var(--card-shadow);
}

button.danger:active {
  transform: scale(0.97);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

button.link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--link);
  padding: 0;
  font-weight: 500;
  font-size: inherit;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

select,
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  width: 100%;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--badge-bg);
}

textarea {
  min-height: 60vh;
  line-height: 1.5;
  font-size: 15px;
  resize: vertical;
}

.field {
  display: block;
  margin: 0 0 12px;
}

.field > span {
  display: block;
  color: var(--hint);
  font-size: 14px;
  margin: 0 2px 6px;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--section);
  border-radius: var(--radius-row);
  padding: 12px 14px;
}

.switch input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.note {
  color: var(--hint);
  font-size: 14px;
  margin: 8px 2px;
}

.note.error {
  color: var(--danger);
}

.switch {
  margin-bottom: 8px;
}

.field.gap {
  margin-top: 12px;
}

button.link.danger-link {
  color: var(--danger);
  margin: 0 2px 12px;
}

/* Тарифы: у каждого своя карточка с ценами в одну строку */
.plans {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.plan {
  background: var(--section);
  border-radius: var(--radius-row);
  padding: 12px 14px 0;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

@media (max-width: 380px) {
  .grid3 {
    grid-template-columns: 1fr 1fr;
  }
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: 1px;
}

.badge.draft {
  background: color-mix(in srgb, var(--stale) 20%, transparent);
  color: var(--stale);
}

.badge.active {
  background: color-mix(in srgb, var(--done) 18%, transparent);
  color: var(--done);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 10;
}

@media (prefers-reduced-motion: no-preference) {
  #toast:not([hidden]) {
    animation: toast-in 0.18s ease-out;
  }

  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translate(-50%, 8px);
    }
  }
}

/* ==========================================
   Шапка приложения и статус-бар (Base44 стиль)
   ========================================== */

.app-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-strong);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform 0.12s ease, border-color 0.15s ease;
  max-width: 52%;
  -webkit-tap-highlight-color: transparent;
}

.model-pill-btn:active {
  transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
  .model-pill-btn:hover {
    border-color: var(--accent);
  }
}

.model-pill-btn .model-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-pill-btn .arrow-down {
  font-size: 9px;
  color: var(--hint);
  flex: none;
}

.credits-meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  white-space: nowrap;
  flex: none;
  -webkit-tap-highlight-color: transparent;
}

.credits-meter b {
  color: var(--accent);
  font-weight: 700;
}

/* Круглые кнопки действий в шапке (переключатель темы, шестерёнка) */
.icon-round-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  box-shadow: var(--card-shadow);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  flex: none;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.icon-round-btn:active {
  transform: scale(0.92);
  background: var(--surface-alt);
}

@media (hover: hover) and (pointer: fine) {
  .icon-round-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.icon-round-btn.active {
  background: var(--badge-bg);
  border-color: var(--accent);
}

/* 4-колоночная фиксированная навигационная панель (нет скрытого скролла) */
.app-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0;
  margin: 0;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--hint);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab .tab-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-tab .tab-label {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-tab.active {
  color: var(--accent);
  background: var(--badge-bg);
  border-color: var(--accent);
  font-weight: 700;
}

.nav-tab:active {
  transform: scale(0.95);
}

@media (hover: hover) and (pointer: fine) {
  .nav-tab:hover:not(.active) {
    border-color: var(--line-strong);
    color: var(--text);
    background: var(--surface-alt);
  }
}

/* ==========================================
   Модальное окно селектора моделей
   ========================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: none;
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  box-shadow: none;
  font-size: 22px;
  color: var(--hint);
  cursor: pointer;
  padding: 4px 8px;
}

.reasoning-box {
  background: color-mix(in srgb, var(--surface-alt) 80%, transparent);
  border-radius: var(--radius-control);
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}

.reasoning-box .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 8px;
  display: block;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--hint);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.segmented-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.profile-card {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  box-shadow: var(--card-shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.profile-card:active {
  transform: scale(0.98);
}

.profile-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.profile-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.profile-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--badge-bg);
  color: var(--accent);
}

.profile-models {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.35;
  margin-bottom: 4px;
}

.profile-hint {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
}

.dynamic-estimate-box {
  margin-top: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-control);
  font-size: 12px;
  line-height: 1.45;
}


.model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--card-shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .model-card-item:hover:not(.locked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  }
}

.model-card-item.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.model-card-item.locked {
  opacity: 0.6;
  background: color-mix(in srgb, var(--hint) 5%, transparent);
}

.model-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}

.model-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.model-desc {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.3;
}

.model-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.tag-credits {
  font-size: 12px;
  font-weight: 700;
  min-width: 56px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--badge-bg);
  color: var(--badge-text);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  flex: none;
  letter-spacing: -0.01em;
}

.model-status-mark {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: none;
}

.crown-tag {
  color: var(--crown);
  font-size: 14px;
}

/* ==========================================
   Экран Библиотека (Library)
   ========================================== */

.library-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lib-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  margin-bottom: 8px;
}

.lib-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.lib-tab:last-child {
  grid-column: 1 / -1;
  justify-content: center;
}

.lib-tab .lib-tab-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

.lib-tab .lib-tab-icon {
  font-size: 16px;
  line-height: 1;
}

.lib-tab .lib-tab-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-tab-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--hint);
  line-height: 1.2;
}

.lib-tab.active {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.lib-tab.active .lib-tab-label {
  color: var(--accent-text);
}

.lib-tab.active .lib-tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: var(--accent-text);
}

.lib-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lib-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lib-card-head .title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.lib-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--surface-alt) 40%, var(--surface));
  padding: 12px 14px;
  border-radius: var(--radius-row);
  border: 1px solid var(--line);
}

.lib-body.doc {
  white-space: normal;
  line-height: 1.55;
}

.lib-body.doc > :first-child {
  margin-top: 0;
}

.lib-body.doc > :last-child {
  margin-bottom: 0;
}

.lib-body.doc h1,
.lib-body.doc h2,
.lib-body.doc h3,
.lib-body.doc h4 {
  font-size: 15px;
  font-weight: 700;
  margin: 0.9em 0 0.35em;
  color: var(--text);
}

.lib-body.doc p {
  margin: 0.6em 0;
}

.lib-body.doc ul,
.lib-body.doc ol {
  padding-left: 20px;
  margin: 0.6em 0;
}

.lib-body.doc li {
  margin-bottom: 0.25em;
}

.lib-body.doc blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 0.8em 0;
  color: var(--text-secondary);
}

.lib-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ==========================================
   Экран Тарифы и Кредиты (Plans & Slider)
   ========================================== */

.plans-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.promo-callout {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid var(--accent);
  border-radius: var(--radius-row);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.promo-callout .text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.promo-callout .old-price {
  font-size: 12px;
  opacity: 0.65;
  text-decoration: line-through;
  white-space: nowrap;
  margin-left: 3px;
}

.promo-callout .badge-discount {
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.billing-period-switch {
  display: flex;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  padding: 4px;
  border-radius: 30px;
  border: 1px solid var(--line);
  width: fit-content;
  margin: 0 auto;
}

.period-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--hint);
  cursor: pointer;
  transition: all 0.15s ease;
}

.period-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.tariff-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 600px) {
  .tariff-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .tariff-grid.single-tariff {
    grid-template-columns: 1fr;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
  }
}

.slider-estimate {
  font-size: 13px;
  color: var(--hint);
  background: var(--bg);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
}

.tariff-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.tariff-card.featured {
  border-color: var(--accent);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--accent) 20%, transparent);
}

.tariff-card-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.tariff-card h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.tariff-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.tariff-price .period-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--hint);
}

.tariff-credits-tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 4px 8px;
  border-radius: 6px;
  width: fit-content;
}

.tariff-features {
  list-style: none;
  padding: 0;
  margin: 4px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.tariff-features li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Ползунок докупки кредитов */
.addon-slider-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.slider-val-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.slider-credits-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.slider-price-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.custom-range {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  border-radius: 4px;
  cursor: pointer;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 6px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 6px;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  cursor: pointer;
  text-align: center;
  box-shadow: var(--card-shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.preset-btn .preset-cr {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.preset-btn .preset-price {
  font-size: 11px;
  font-weight: 500;
  color: var(--hint);
  white-space: nowrap;
}

.preset-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.preset-btn.selected {
  border-color: var(--accent);
  background: var(--badge-bg);
  color: var(--accent);
}

.preset-btn.selected .preset-cr {
  color: var(--accent);
}

.addon-locked-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-row);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  z-index: 5;
}

.addon-locked-overlay p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ==========================================
   АДМИНКА, ПРОМОКОДЫ И РЕФЕРАЛКА
   ========================================== */

.admin-nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}
@media (max-width: 480px) {
  .admin-nav-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
.admin-nav-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.admin-nav-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.admin-nav-card .icon {
  font-size: 24px;
  margin-bottom: 6px;
}
.admin-nav-card .title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}
.admin-nav-card .sub {
  font-size: 12px;
  color: var(--hint);
}

.admin-user-card, .admin-promo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.admin-card-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.admin-card-head .badge {
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0;
}
.nowrap {
  white-space: nowrap;
}
.admin-modal-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.admin-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.admin-modal-actions button {
  flex: 1;
}
.admin-card-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.admin-card-meta {
  font-size: 12px;
  color: var(--hint);
}
.admin-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.admin-card-actions button {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* Формы промокодов и рефералки */
.promo-box, .ref-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 16px;
  margin-bottom: 24px;
}

/* ==========================================
   АНАЛИТИКА И ВОРОНКА КОНВЕРСИЙ
   ========================================== */

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 20px;
}
@media (min-width: 600px) {
  .analytics-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 6px;
  font-weight: 500;
}
.kpi-card .kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi-card .kpi-sub {
  font-size: 11px;
  color: var(--hint);
  margin-top: 4px;
}

.funnel-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 16px;
  margin-bottom: 20px;
}
.funnel-step-item {
  margin-bottom: 14px;
}
.funnel-step-item:last-child {
  margin-bottom: 0;
}
.funnel-step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}
.funnel-step-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.funnel-step-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
}
.funnel-dropoff {
  font-size: 11px;
  color: #ff3b30;
  background: rgba(255, 59, 48, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}
.funnel-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.funnel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #34c759 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ==========================================
   МАССОВАЯ РАССЫЛКА
   ========================================== */

.broadcast-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 16px;
  margin-bottom: 20px;
}
.broadcast-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.broadcast-tab {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
  background: var(--card-bg, rgba(120, 120, 128, 0.1));
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.broadcast-tab.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}
.broadcast-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.broadcast-toolbar button {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--card-bg, rgba(120, 120, 128, 0.1));
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.broadcast-toolbar button:hover {
  background: var(--border);
}

.telegram-preview {
  border-radius: 16px 16px 16px 4px;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.2);
  padding: 14px 16px;
  margin: 14px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.telegram-preview-photo {
  max-width: 100%;
  border-radius: 10px;
  margin-bottom: 10px;
  display: block;
}
.telegram-preview-btn {
  margin-top: 10px;
  display: block;
  text-align: center;
  background: rgba(0, 122, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 13px;
}
.broadcast-progress-box {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  margin-top: 16px;
}
.broadcast-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* ==========================================
   КЛИКАБЕЛЬНАЯ АНАЛИТИКА И CRM-ТАБЛИЦА ПОЛЬЗОВАТЕЛЕЙ
   ========================================== */

@media (min-width: 960px) {
  #app.admin-wide {
    max-width: 1180px;
  }
}

.analytics-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.analytics-refresh-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 12px;
}

.kpi-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.kpi-head-row .kpi-label {
  margin-bottom: 0;
}
.drill-arrow {
  color: var(--hint);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.7;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.kpi-card.clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-card.clickable:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.kpi-card.clickable:hover .drill-arrow,
.funnel-step-item.clickable:hover .drill-arrow,
.analytics-clickable-row:hover .drill-arrow {
  color: var(--accent);
  opacity: 1;
  transform: translateX(2px);
}
.kpi-card.clickable:active {
  transform: scale(0.99);
}

.kpi-sub-link {
  display: inline;
  width: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}
.kpi-sub-link:hover {
  color: var(--accent);
}

.funnel-step-item.clickable {
  cursor: pointer;
  padding: 8px 10px;
  margin: 0 -10px 6px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.funnel-step-item.clickable:last-child {
  margin-bottom: 0;
}
.funnel-step-item.clickable:hover {
  background: rgba(127, 127, 127, 0.08);
}

.funnel-dropoff-btn {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 0;
  border: 1px solid rgba(255, 59, 48, 0.25);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.funnel-dropoff-btn:hover {
  background: rgba(255, 59, 48, 0.2);
  border-color: rgba(255, 59, 48, 0.5);
}

.analytics-clickable-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.analytics-clickable-row:last-child {
  border-bottom: none;
}
.analytics-clickable-row:hover {
  background: rgba(127, 127, 127, 0.08);
}
.analytics-row-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.clickable-badge {
  width: auto;
  min-height: 0;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.clickable-badge:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Шапка и контролы экрана Пользователей */
.admin-users-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.view-mode-switch {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}
.view-mode-switch .preset-btn {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.admin-slice-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid rgba(255, 107, 53, 0.28);
}
.admin-slice-text {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}
.admin-slice-title {
  font-weight: 600;
  color: var(--text);
}
.link-btn {
  display: inline;
  width: auto;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.small-chip-btn {
  width: auto;
  min-height: 0;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.admin-context-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}
.admin-users-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.admin-users-controls input {
  flex: 1 1 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.admin-users-controls select {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.admin-filter-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.admin-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.admin-chips-row::-webkit-scrollbar {
  display: none;
}
.admin-chips-row .preset-btn {
  padding: 6px 11px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Расширенная карточка пользователя (мобильный + универсальный вид) */
.admin-card-sub-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.user-sub-src {
  font-size: 11px;
  color: var(--hint);
}
.badge.expired {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.3);
}
.badge.promo-tag {
  background: rgba(175, 82, 222, 0.12);
  color: #af52de;
  border-color: rgba(175, 82, 222, 0.3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.badge.extra-tag {
  background: rgba(255, 149, 0, 0.14);
  color: #e67e00;
  border-color: rgba(255, 149, 0, 0.35);
}

.user-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}
@media (max-width: 370px) {
  .user-meta-grid {
    grid-template-columns: 1fr;
  }
}
.user-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.user-meta-label {
  font-size: 11px;
  color: var(--hint);
}
.user-meta-val {
  font-size: 12px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.35;
}
.user-tg-link {
  color: var(--accent);
  font-weight: 500;
}
.user-tg-link:hover {
  text-decoration: underline;
}
.btn-link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.btn-link-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* CRM-таблица пользователей (ПК и широкий просмотр) */
.admin-users-table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  -webkit-overflow-scrolling: touch;
}
.admin-users-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-users-table th {
  text-align: left;
  padding: 11px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--hint);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.admin-users-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
  line-height: 1.4;
}
.admin-users-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-users-table tbody tr:hover td {
  background: rgba(127, 127, 127, 0.04);
}
.tbl-user-name {
  font-weight: 600;
  font-size: 13px;
}
.tbl-user-meta {
  font-size: 11px;
  color: var(--hint);
}
.tbl-sub-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.tbl-spend-line {
  font-size: 12px;
  margin-top: 2px;
}
.user-mini-muted {
  font-size: 11px;
  color: var(--hint);
}
.tbl-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}
.tbl-actions button,
.tbl-actions .btn-link-action {
  width: auto;
  min-height: 0;
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 7px;
}

/* ==========================================
   МИНИМАЛИСТИЧНЫЙ ГРАФИК ПРИРОСТА ПОЛЬЗОВАТЕЛЕЙ
   ========================================== */

.growth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.growth-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.growth-head-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.growth-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.growth-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255, 107, 53, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.growth-toggle-btn {
  width: auto;
  min-height: 0;
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.growth-head:hover .growth-toggle-btn {
  color: var(--accent);
}
.growth-body {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.growth-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.growth-hover-info {
  font-size: 12px;
  color: var(--hint);
}
.growth-hover-info strong {
  color: var(--text);
}
.growth-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.growth-seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.growth-seg-btn {
  width: auto;
  min-height: 0;
  padding: 3px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--hint);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.growth-seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.growth-svg-wrap {
  width: 100%;
  overflow: hidden;
}
.growth-svg {
  width: 100%;
  height: auto;
  display: block;
}
.growth-grid-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.growth-axis-text {
  fill: var(--hint);
  font-size: 10px;
  font-family: inherit;
}
.growth-bar {
  fill: var(--accent);
  opacity: 0.78;
  transition: opacity 0.15s ease;
}
.growth-bar.zero {
  fill: var(--hint);
  opacity: 0.18;
}
.growth-point.active .growth-bar,
.growth-point:hover .growth-bar {
  opacity: 1;
}
.growth-line {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.growth-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  transition: r 0.15s ease, fill 0.15s ease;
}
.growth-point.active .growth-dot,
.growth-point:hover .growth-dot {
  fill: var(--accent);
}
.growth-hit {
  fill: transparent;
  cursor: pointer;
}

/* ==========================================
   ВИЗУАЛЬНЫЙ РЕДАКТОР РАССЫЛОК И ЗАГРУЗКА МЕДИА
   ========================================== */

.wysiwyg-editor {
  min-height: 132px;
  max-height: 360px;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  transition: border-color 0.15s ease;
}
.wysiwyg-editor:focus {
  border-color: var(--accent);
}
.wysiwyg-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--hint);
  pointer-events: none;
}
.wysiwyg-editor a,
.telegram-preview-text a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wysiwyg-editor code,
.telegram-preview-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(127, 127, 127, 0.15);
}

.broadcast-editor-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--hint);
}
.broadcast-char-count {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}
.broadcast-char-count.over-limit {
  color: #ff3b30;
}

.broadcast-btn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .broadcast-btn-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.broadcast-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.broadcast-dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.broadcast-dropzone:hover,
.broadcast-dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.06);
}
.broadcast-dropzone.uploading {
  opacity: 0.75;
  cursor: wait;
}
.broadcast-dropzone-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}
.broadcast-dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--text);
}
.broadcast-dropzone-text span {
  font-size: 11px;
  color: var(--hint);
}

.broadcast-uploaded-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.broadcast-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}
.broadcast-uploaded-info {
  flex: 1;
  min-width: 0;
}
.broadcast-uploaded-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.broadcast-uploaded-meta {
  font-size: 11px;
  color: var(--hint);
  margin-top: 2px;
}

.broadcast-url-details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--hint);
}
.broadcast-url-details summary {
  cursor: pointer;
  user-select: none;
}

.telegram-preview-video {
  width: 100%;
  max-height: 280px;
  border-radius: 10px;
  margin-bottom: 10px;
  display: block;
  background: #000;
}

/* ==========================================
   МОДАЛКА ВЫБОРА СПОСОБА ОПЛАТЫ (STARS / КАРТА / КРИПТА)
   ========================================== */

.pm-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pm-option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.pm-option-btn:hover {
  border-color: var(--accent);
}
.pm-option-btn:active {
  transform: scale(0.99);
}
.pm-option-btn.pm-stars {
  border-color: rgba(255, 165, 0, 0.45);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.12) 0%, rgba(255, 107, 53, 0.08) 100%);
}
.pm-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}
.pm-body {
  flex: 1;
  min-width: 0;
}
.pm-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.pm-sub {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
  line-height: 1.35;
}
.pm-price-tag {
  font-size: 12px;
  font-weight: 700;
  color: #d97706;
  background: rgba(245, 158, 11, 0.16);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pm-discount-badge {
  font-size: 11px;
  font-weight: 700;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.14);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}






