/* ============================================================
   AgentSMM — дизайн-система
   Темы: [data-theme="dark"] (по умолчанию) / [data-theme="light"]
   ============================================================ */

:root[data-theme="dark"] {
  --bg: #0a0d16;
  --bg-soft: #0d1120;
  --surface: #111627;
  --surface-2: #161d33;
  --surface-3: #1c2440;
  --border: #222b47;
  --border-strong: #2e3a61;
  --text: #e9edf7;
  --muted: #9aa5c4;
  --faint: #5f6b8f;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, .14);
  --grad: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --success: #34d399;   --success-bg: rgba(52, 211, 153, .13);
  --warn: #fbbf24;      --warn-bg: rgba(251, 191, 36, .13);
  --danger: #fb7185;    --danger-bg: rgba(251, 113, 133, .13);
  --shadow-lg: 0 24px 60px -12px rgba(2, 6, 23, .65);
  --shadow-md: 0 10px 30px -8px rgba(2, 6, 23, .55);
  --shadow-glow: 0 8px 28px -6px rgba(124, 92, 255, .45);
  --tile-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  --scroll: #2a3354;
  --input-bg: #0d1222;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f4fb;
  --bg-soft: #eef1fa;
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --surface-3: #eceff8;
  --border: #e2e7f3;
  --border-strong: #ccd5ea;
  --text: #17203a;
  --muted: #5b6785;
  --faint: #97a1bd;
  --accent: #6a4cf7;
  --accent-2: #0891b2;
  --accent-soft: rgba(106, 76, 247, .10);
  --grad: linear-gradient(135deg, #6a4cf7 0%, #0ea5e9 100%);
  --success: #0d9e74;   --success-bg: rgba(13, 158, 116, .12);
  --warn: #c07c05;      --warn-bg: rgba(192, 124, 5, .12);
  --danger: #e11d48;    --danger-bg: rgba(225, 29, 72, .10);
  --shadow-lg: 0 24px 60px -14px rgba(23, 32, 58, .18);
  --shadow-md: 0 10px 30px -10px rgba(23, 32, 58, .14);
  --shadow-glow: 0 8px 28px -6px rgba(106, 76, 247, .35);
  --tile-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
  --scroll: #c9d2e8;
  --input-bg: #ffffff;
  color-scheme: light;
}

/* ---------- база ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
::selection { background: rgba(124, 92, 255, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- фоновые сферы ---------- */
.orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; animation: drift 26s ease-in-out infinite alternate; }
.o1 { width: 520px; height: 520px; left: -140px; top: -160px; background: radial-gradient(circle, rgba(124,92,255,.55), transparent 65%); }
.o2 { width: 460px; height: 460px; right: -120px; top: 30%; background: radial-gradient(circle, rgba(34,211,238,.4), transparent 65%); animation-delay: -8s; }
.o3 { width: 400px; height: 400px; left: 35%; bottom: -180px; background: radial-gradient(circle, rgba(236,72,153,.32), transparent 65%); animation-delay: -16s; }
:root[data-theme="light"] .orb { opacity: .35; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, -40px) scale(1.12); }
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 75%);
}
:root[data-theme="light"] .grid-overlay {
  background-image: linear-gradient(rgba(23,32,58,.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(23,32,58,.04) 1px, transparent 1px);
}

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center; box-shadow: var(--shadow-glow);
}
.brand-text b { font-size: 17px; letter-spacing: -.02em; display: block; line-height: 1.2; }
.brand-text span { font-size: 12px; color: var(--muted); display: block; }

/* ============================================================
   АВТОРИЗАЦИЯ
   ============================================================ */
.auth-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-wrap {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0;
  width: min(1060px, 100%); border-radius: 28px; overflow: hidden;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}
.auth-hero { position: relative; padding: 56px 52px; background:
  radial-gradient(120% 120% at 0% 0%, rgba(124,92,255,.28), transparent 50%),
  radial-gradient(120% 120% at 100% 100%, rgba(34,211,238,.22), transparent 50%),
  var(--surface-2);
  display: flex; align-items: center;
}
.auth-hero-inner { position: relative; z-index: 1; width: 100%; }

/* карточка-превью продукта вместо маркетингового заголовка */
.hero-preview {
  margin: 34px 0 26px; max-width: 470px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border-strong); border-radius: 18px;
  padding: 16px 18px; box-shadow: var(--shadow-md);
}
.hp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.hp-title { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.hp-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
/* ротация публикаций: колонка фиксированной высоты на 2 строки */
.hp-list { position: relative; height: 114px; overflow: hidden; }
.hp-list .hp-row {
  position: absolute; left: 0; right: 0; top: 0; height: 57px; padding: 0;
  transition: transform .65s cubic-bezier(.3, .7, .25, 1), opacity .55s ease;
}
.hp-time { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.hp-main { flex: 1; min-width: 0; }
.hp-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-main span { font-size: 12px; color: var(--muted); }
.hp-nets { display: flex; gap: 4px; }
.hp-nets i { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 8.5px; font-style: normal; font-weight: 800; color: #fff; }
.hp-agent { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--muted); height: 28px; overflow: hidden; }
.hp-agent-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-av { width: 26px; height: 26px; border-radius: 8px; color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.hp-agent b { color: var(--text); font-weight: 600; }
.hp-when { color: var(--faint); white-space: nowrap; }

/* живость верхней части: точка «скоро выйдет» и полоса-прогресс до времени публикации */
.hp-row { position: relative; }
.hp-soon { position: relative; padding-left: 11px; color: var(--accent); }
:root[data-theme="light"] .hp-soon { color: #6a4cf7; }
.hp-soon::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
  animation: hpPulse 2.2s ease-in-out infinite;
}
.hp-progress {
  position: absolute; left: 18px; right: 18px; top: 55px; height: 2.5px;
  border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left center; transform: scaleX(.18); opacity: .45;
  animation: hpProgress 12s cubic-bezier(.4, 0, .4, 1) infinite; pointer-events: none;
}
@keyframes hpProgress {
  0% { transform: scaleX(.18); opacity: .3; }
  55% { transform: scaleX(.72); opacity: .5; }
  100% { transform: scaleX(1); opacity: .6; }
}

/* анимация карточки-превью: появление строк, пульс «сегодня», живая лента агентов */
.hero-preview > * { animation: viewIn .5s backwards; }
.hero-preview > *:nth-child(2) { animation-delay: .12s; }
.hero-preview > *:nth-child(3) { animation-delay: .24s; }
.hero-preview > *:nth-child(4) { animation-delay: .36s; }
.hero-preview .badge::before { animation: hpPulse 2.2s ease-in-out infinite; }
@keyframes hpPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.hp-agent { transition: opacity .4s ease, transform .4s ease; }
.hp-agent.fade { opacity: 0; transform: translateY(6px); }
.hp-typing { display: inline-flex; gap: 5px; align-items: center; padding: 2px 0; }
.hp-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.hp-typing i:nth-child(2) { animation-delay: .15s; }
.hp-typing i:nth-child(3) { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) {
  .hero-preview *, .hp-agent { animation: none !important; transition: none !important; }
}

.hero-points { list-style: none; display: grid; gap: 13px; margin-bottom: 30px; }
.hero-points li { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14.5px; }
.pt-ic {
  flex: 0 0 24px; height: 24px; border-radius: 8px; display: grid; place-items: center;
  background: var(--success-bg); color: var(--success); font-size: 12px; font-weight: 700;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-mini {
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--muted);
}
.auth-card { padding: 44px 44px 36px; background: color-mix(in srgb, var(--surface) 75%, transparent); }
.auth-card-head h2 { font-size: 24px; letter-spacing: -.02em; }
.auth-card-head p { color: var(--muted); font-size: 14px; margin: 4px 0 22px; }

.auth-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-3); border-radius: 12px; padding: 4px; margin-bottom: 24px; }
.auth-tab { position: relative; z-index: 1; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); transition: color .2s; }
.auth-tab.active { color: var(--text); }
.auth-tab-ink { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px); background: var(--surface); border-radius: 9px; box-shadow: var(--shadow-md); transition: transform .25s cubic-bezier(.4, 0, .2, 1); }
.auth-tabs[data-active="register"] .auth-tab-ink { transform: translateX(100%); }

.auth-alt { text-align: center; color: var(--muted); font-size: 14px; margin-top: 18px; }
.auth-foot { margin-top: 26px; color: var(--faint); font-size: 12.5px; }

/* ---------- поля формы ---------- */
.field { margin-bottom: 12px; }

.oauth-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: 14px;
  padding: 11px 14px;
  color: var(--acc);
  border-color: var(--acc) !important;
  background: color-mix(in srgb, var(--acc) 8%, transparent) !important;
}
.oauth-btn:hover { filter: brightness(1.08); }
.oauth-hint { margin: -6px 0 12px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.oauth-hint code { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--acc); }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.input-wrap { position: relative; }
.input-wrap input, .input-wrap select, .input-wrap textarea {
  width: 100%; padding: 9px 13px; border-radius: 11px; resize: none;
  background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); outline: none; transition: border-color .18s, box-shadow .18s;
}
.input-wrap input::placeholder, .input-wrap textarea::placeholder { color: var(--faint); }
.input-wrap input:focus, .input-wrap select:focus, .input-wrap textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.input-wrap input.invalid { border-color: var(--danger); }
.input-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: var(--faint);
}
.input-eye:hover { color: var(--text); background: var(--surface-3); }
.field-err { color: var(--danger); font-size: 12.5px; margin-top: 6px; min-height: 0; display: none; }
.field-err.show { display: block; }
.pass-meter { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 8px; overflow: hidden; }
.pass-meter span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--danger); transition: width .25s, background .25s; }

.check-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox {
  width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  background: var(--input-bg); display: grid; place-items: center; transition: .18s; flex-shrink: 0;
}
.checkbox::after { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--grad); transform: scale(0); transition: transform .18s cubic-bezier(.4, 0, .2, 1); }
.check-row input:checked + .checkbox { border-color: var(--accent); }
.check-row input:checked + .checkbox::after { transform: scale(1); }
.check-row.invalid .checkbox { border-color: var(--danger); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: .18s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn .spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent; position: relative; transition: .18s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 9px; right: 10px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2.5px var(--bg);
}
.burger { display: none; }

/* ============================================================
   КАРКАС ПРИЛОЖЕНИЯ
   ============================================================ */
/* шапка на всю ширину, чат слева начинается под ней */
.app {
  --chat-w: 500px;
  display: grid; grid-template-columns: var(--chat-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "topbar topbar" "chat main";
  min-height: 100vh;
  transition: grid-template-columns .28s ease;
}

/* панель чата задвинута: колонка схлопывается, содержимое уезжает влево */
.app.chat-hidden { grid-template-columns: 0px minmax(0, 1fr); }

/* ушка возврата панели чата: видна у левого края только когда чат свёрнут */
.chat-open-fab {
  position: fixed; z-index: 45; left: 0;
  top: calc(var(--topbar-h, 56px) + (100vh - var(--topbar-h, 56px)) / 2);
  width: 26px; height: 64px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow-md);
}
.chat-open-fab svg { width: 14px; height: 14px; }
.chat-open-fab:hover { color: var(--text); background: var(--surface-2); }
.chat-open-fab[hidden] { display: none; }

/* левая панель: глобальный чат с Оркестратором на всех страницах.
   top = высоте шапки: панель уходит под её подложку при прокрутке */
.chat-side {
  grid-area: chat;
  position: sticky; top: var(--topbar-h, 56px); height: calc(100vh - var(--topbar-h, 56px));
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden; z-index: 40;
}
.side-brand { padding: 0 8px; }
.chat-side > #chat-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* чат в панели выглядит как карточка (раньше его обёрткой была .card на странице «Агенты») */
.chat-side .chat-wrap {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-md);
  margin: 12px 0 12px 12px;
}
/* тонкий скроллбар в чате: не съедает ширину ленты сообщений */
.chat-side * { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.chat-side *::-webkit-scrollbar { width: 6px; height: 6px; }
.chat-side *::-webkit-scrollbar-track { background: transparent; }
.chat-side *::-webkit-scrollbar-thumb { background: var(--surface-3); border: none; border-radius: 999px; }
.chat-side *::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* вкладки навигации в шапке — по центру между брендом и действиями */
.top-nav {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px;
  color: var(--muted); font-weight: 500; font-size: 13px; text-align: left;
  transition: .16s; position: relative; white-space: nowrap; flex-shrink: 0;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-item .nav-badge {
  margin-left: 2px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}

.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 15px;
  display: grid; place-items: center;
}

.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  grid-area: topbar;
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 4px 20px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
/* бренд в шапке — компактный вариант блока AgentSMM */
/* бренд в шапке — компактный вариант блока AgentSMM */
.topbar-brand { gap: 7px; margin-right: 6px; }
.topbar-brand .brand-logo { flex-basis: 28px; width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.topbar-brand .brand-text b { font-size: 13.5px; }
.topbar-brand .brand-text span { font-size: 10px; }
/* кнопки и профиль в шапке — уменьшенные под низкую шапку */
.topbar .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
.topbar-user { padding: 2px 8px 2px 2px; gap: 8px; }
.topbar-user .avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }
.topbar-user .tu-name { font-size: 13px; }
.topbar-user { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px 5px 5px; border-radius: 12px; transition: .16s; }
.topbar-user:hover { background: var(--surface-3); }
.topbar-user .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
.topbar-user .tu-name { font-size: 14px; font-weight: 600; }
.topbar-user svg { width: 14px; height: 14px; color: var(--muted); }

.content { padding: 18px 28px 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.view-enter { animation: viewIn .32s cubic-bezier(.25, .6, .3, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* выпадающее меню */
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 230px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 8px; animation: viewIn .18s ease;
}
.dd-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-head b { display: block; font-size: 14px; }
.dd-head span { font-size: 12.5px; color: var(--muted); }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 14px; color: var(--text); text-align: left; }
.dd-item:hover { background: var(--surface-3); }
.dd-item svg { width: 17px; height: 17px; color: var(--muted); }
.dd-item.danger, .dd-item.danger svg { color: var(--danger); }
.dd-note { display: flex; gap: 11px; padding: 11px 12px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 6px; }
.dd-note svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); margin-top: 1px; }

/* ============================================================
   ОБЩИЕ БЛОКИ
   ============================================================ */
.card {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-md);
}
.card-pad { padding: 15px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.card-head h3 svg { width: 18px; height: 18px; color: var(--accent); }
.card-head .hint { font-size: 12.5px; color: var(--faint); }

.grid { display: grid; gap: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* бейджи */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.off { background: var(--surface-3); color: var(--faint); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="light"] .badge.acc { color: #6a4cf7; }

/* тайлы брендов */
.tile {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px;
  letter-spacing: -.02em; box-shadow: var(--tile-shadow), 0 6px 16px -6px rgba(0,0,0,.4);
}

/* переключатель */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: .2s; }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: .2s cubic-bezier(.4, 0, .2, 1);
}
.switch input:checked + .track { background: var(--grad); border-color: transparent; }
.switch input:checked + .track::after { left: 21px; background: #fff; }

/* toggle-строка (крупная) */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .tr-text b { display: block; font-size: 14px; font-weight: 600; }
.toggle-row .tr-text span { font-size: 12.5px; color: var(--muted); }

/* слайдер */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 5px; background: var(--surface-3); outline: none; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; border: 4px solid var(--accent); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output { min-width: 42px; text-align: center; font-weight: 700; font-size: 13.5px; background: var(--surface-3); border-radius: 8px; padding: 4px 8px; font-variant-numeric: tabular-nums; }

/* селект */
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 38px; cursor: pointer; }
.select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

/* секции с заголовком */
.sec-title { display: flex; align-items: center; gap: 10px; margin: 20px 0 10px; }
.sec-title:first-child { margin-top: 0; }
.sec-title h3 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sec-title .cnt { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }
.sec-title .line { flex: 1; height: 1px; background: var(--border); }
.sec-title svg { width: 17px; height: 17px; color: var(--accent); }

/* сегментные вкладки (AI-модели) */
.seg { display: inline-flex; gap: 4px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.seg-btn { padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; transition: .15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.seg-btn svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); }
.seg-btn.on svg { color: var(--accent); }
.seg-btn .cnt { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }

/* пустое состояние */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; margin: 0 auto 14px; color: var(--faint); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 5px; }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 16px; }

/* скелетон загрузки */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 12px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ============================================================
   ДАШБОРД
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.stat {
  position: relative; overflow: hidden; padding: 11px 14px; text-align: left;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border); border-radius: 16px; cursor: pointer; transition: .18s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.stat .st-ic {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  margin-bottom: 9px; background: var(--accent-soft); color: var(--accent);
}
.stat .st-ic svg { width: 16px; height: 16px; }
.stat .st-ic.green { background: var(--success-bg); color: var(--success); }
.stat .st-ic.cyan { background: rgba(34,211,238,.13); color: var(--accent-2); }
.stat .st-ic.warm { background: var(--warn-bg); color: var(--warn); }
.stat .st-val { font-size: 21px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat .st-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--accent-soft); filter: blur(6px); }

/* ---------- Статистика расхода моделей ---------- */
/* плитки здесь просто показатели: наводить на них нечего */
.stat-plain { cursor: default; }
.stat-plain:hover { border-color: var(--border); transform: none; box-shadow: none; }
.stat-plain::after { display: none; }

.usage-note { font-size: 12.5px; color: var(--faint); margin: 10px 0 0; }
.usage-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Один график на оба показателя. Единицы разные, поэтому две вертикальные
   шкалы: столбики (запросы) по левой, линия (токены) по правой. Дни — отдельная
   строка под полотном: пока подпись жила внутри колонки, высокий столбик
   вытеснял её за пределы графика и дата просто не рисовалась */
.usage-chart { padding-top: 4px; }
/* место сверху reserved под подписи шкал, чтобы они не наезжали на столбики */
.ub-plot { position: relative; padding: 20px 8px 0; }
.ub-scale { position: absolute; top: 0; display: flex; align-items: baseline; gap: 5px; font-size: 10.5px; color: var(--faint); line-height: 1; }
.ub-scale b { font-size: 12px; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ub-scale-l { left: 8px; }
.ub-scale-r { right: 8px; }
.ub-canvas { position: relative; }
.ub-glines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.ub-glines i { display: block; height: 1px; background: var(--border); opacity: .55; }
.ub-grid { display: flex; align-items: flex-end; gap: 2px; }
.ub-bars { height: 152px; }
.ub-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
/* пара столбиков на день: слева запросы (левая шкала), справа токены (правая).
   Ряды стоят рядом, а не один на другом: наложенная линия рядом с тяжёлыми
   столбиками выглядела дохлой, а заливка под ними просто ими закрывалась */
.ub-pair { display: flex; align-items: flex-end; gap: 1px; height: 100%; }
.ub-bar {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column-reverse; width: 100%;
  border-radius: 4px 4px 0 0; overflow: hidden; min-height: 0;
  transition: filter .15s;
}
.ub-bar-tokens { background: var(--accent); }
.ub-col:hover .ub-bar { filter: brightness(1.12); }
.ub-bar i { display: block; width: 100%; }
.ub-axis { align-items: flex-start; height: auto; margin-top: 7px; }
.ub-axis .ub-col { height: auto; }
.ub-axis span { font-size: 10px; color: var(--faint); text-align: center; white-space: nowrap; overflow: hidden; }
/* на 90 днях подписи сливаются — оставляем только первые, средние и последние */
.usage-chart[data-days="90"] .ub-axis .ub-col span { visibility: hidden; }
.usage-chart[data-days="90"] .ub-axis .ub-col:first-child span,
.usage-chart[data-days="90"] .ub-axis .ub-col:nth-child(45) span,
.usage-chart[data-days="90"] .ub-axis .ub-col:last-child span { visibility: visible; }

.usage-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.usage-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.usage-legend .lg i { width: 9px; height: 9px; border-radius: 3px; }
/* в легенде токены — сплошной столбик, поэтому значок заливкой. Правило после
   базового .lg i: specificity у них одинаковая, решает порядок в файле */
.usage-legend .lg-tokens { background: var(--accent); }

.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px;
}
.usage-table td { padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.usage-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-table code { font-size: 12.5px; }
.usage-table .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
/* доля рисуется полоской: так сравнение видно сразу, а не по цифрам в столбце */
.usage-table .share { width: 120px; white-space: nowrap; }
.usage-table .share i { display: inline-block; height: 7px; border-radius: 4px; vertical-align: middle; max-width: 84px; }
.usage-table .share span { font-size: 12px; color: var(--muted); margin-left: 8px; font-variant-numeric: tabular-nums; }

.usage-sources { display: flex; flex-direction: column; gap: 12px; }
.us-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.us-top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.us-bar { height: 7px; border-radius: 4px; background: var(--surface-3); margin: 6px 0 3px; overflow: hidden; }
.us-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.us-sub { font-size: 11.5px; color: var(--faint); }

.hero-banner {
  position: relative; overflow: hidden; border-radius: 16px; padding: 11px 18px; margin-bottom: 12px;
  background: linear-gradient(120deg, rgba(124,92,255,.32), rgba(34,211,238,.18)), var(--surface-2);
  border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.hero-banner h3 { font-size: 16px; letter-spacing: -.02em; margin-bottom: 3px; }
.hero-banner p { color: var(--muted); font-size: 13px; max-width: 560px; }
.hero-banner .btn { position: relative; z-index: 1; }

.dash-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.up-row { display: flex; align-items: center; gap: 13px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.up-row.click { cursor: pointer; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 10px; transition: background .15s; }
.up-row.click:hover { background: var(--surface-2); }
.up-row.click:last-child { border-bottom-color: transparent; }
.up-row:last-child { border-bottom: none; }
.up-time {
  min-width: 50px; text-align: center; padding: 5px 4px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.up-time b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.up-time span { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.up-row .up-main { flex: 1; min-width: 0; }
.up-row .up-main b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-row .up-main span { font-size: 12.5px; color: var(--muted); }
.net-dots { display: flex; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.net-dots .nd { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 8.5px; font-weight: 800; color: #fff; flex-shrink: 0; }
.net-dots .nd.more { background: var(--surface-3) !important; color: var(--muted) !important; font-size: 8px; border: 1px solid var(--border); }

/* плитки действий: авторазмер, чтобы новое число кнопок не разъезжало блок */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick {
  display: flex; flex-direction: column; gap: 6px; padding: 11px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--border); transition: .18s; text-align: left;
}
.quick:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.quick-accent { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); }
.quick-accent .q-ic { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); }
.quick .q-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.quick .q-ic svg { width: 17px; height: 17px; }
.quick b { font-size: 13.5px; }
.quick span { font-size: 12px; color: var(--muted); }

.setup-list { display: grid; gap: 4px; }
.setup-item { display: flex; align-items: center; gap: 13px; padding: 5px 0; }
.setup-item .si-n { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--faint); border: 1px solid var(--border); }
.setup-item .si-n svg { width: 13px; height: 13px; }
.setup-item.done .si-n { background: var(--success-bg); color: var(--success); border-color: transparent; }
.setup-item .si-main { flex: 1; }
.setup-item .si-main b { font-size: 14px; display: block; }
.setup-item .si-main span { font-size: 12.5px; color: var(--muted); }

/* ============================================================
   КАЛЕНДАРЬ
   ============================================================ */
.cal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cal-month { display: flex; align-items: baseline; gap: 8px; }
.cal-month h3 { font-size: 18px; letter-spacing: -.02em; text-transform: capitalize; }
.cal-month span { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-nav { display: flex; gap: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; }
.cal-dow { padding: 7px 6px; text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); border-bottom: 1px solid var(--border); }
.cal-cell {
  position: relative; min-height: 82px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s; overflow: hidden;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { opacity: .38; }
.cal-cell.today .cal-daynum {
  background: var(--grad); color: #fff; box-shadow: var(--shadow-glow);
}
.cal-daynum {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; font-variant-numeric: tabular-nums;
}
.cal-posts { display: flex; flex-direction: column; gap: 4px; }
.cal-chip {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 8px; background: var(--surface-3); border-left: 3px solid var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; width: 100%;
}
.cal-chip:hover { filter: brightness(1.15); }
.cal-chip .cc-net { display: flex; gap: 2px; flex-shrink: 0; }
.cal-chip .cc-net i { width: 13px; height: 13px; border-radius: 4px; display: grid; place-items: center; font-size: 6.5px; font-style: normal; font-weight: 800; color: #fff; }
.cal-chip b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.status-scheduled { border-left-color: var(--accent); }
/* уже вышедшие — серые: приглушаем и обесцвечиваю весь чип */
.cal-chip.status-published { border-left-color: var(--border-strong); opacity: .55; filter: grayscale(1); }
.cal-chip.status-published:hover { filter: grayscale(1) brightness(1.15); }
.cal-more { font-size: 10.5px; color: var(--faint); font-weight: 600; padding-left: 4px; }

/* --- Вкладка «Публикации»: всё на одном экране ---
   сверху недельная лента (7 дней с публикациями), ниже четыре равноправные
   колонки списков (в работе / готовы / ближайшие / опубликованные) —
   рост любого списка не сдвигает остальные */
.pub-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  height: calc(100vh - 116px);
  min-height: 470px;
}
/* на средних экранах четыре колонки тесны — складываем 2×2 */
@media (max-width: 1440px) {
  .pub-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  }
}
.wk-strip { grid-column: 1 / -1; min-width: 0; }
.wk-scroll { overflow-x: auto; }
.wk-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.wk-day { border-right: 1px solid var(--border); padding: 7px 8px 8px; min-height: 96px; }
.wk-day:last-child { border-right: none; }
.wk-day:hover { background: var(--surface-2); }
.wk-day.today { background: var(--accent-soft); }
.wk-day.today:hover { background: var(--accent-soft); }
/* на подсвеченном фоне тон ячейки близок к --surface-3 — чипам даём базовую поверхность,
   чтобы запланированные посты читались на фоне подсветки */
.wk-day.today .cal-chip { background: var(--surface); }
.wk-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; background: none; border: none; padding: 0; cursor: pointer; }
.wk-dow { font-size: 10.5px; text-transform: uppercase; color: var(--faint); font-weight: 700; letter-spacing: .04em; }
.wk-head b { font-size: 12.5px; font-weight: 600; color: var(--muted); width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.wk-posts { display: flex; flex-direction: column; gap: 4px; }
.wk-more { font-size: 10.5px; color: var(--faint); font-weight: 600; }

/* полный месяц в модалке */
.mm-wrap { min-width: 0; }
.mm-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mm-nav b { font-size: 15px; }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.mm-grid .cal-dow { border-bottom: none; padding: 4px 2px; }
.mm-cell { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; padding: 7px 6px; min-height: 52px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: pointer; transition: border-color .15s; }
.mm-cell:hover { border-color: var(--accent); }
.mm-cell.out { opacity: .4; }
.mm-cell b { font-size: 12px; font-weight: 600; color: var(--muted); width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; }
.mm-cell.today b { background: var(--grad); color: #fff; }
.mm-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.mm-dots i { width: 7px; height: 7px; border-radius: 50%; }

.pub-sec { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pub-sec .card-head { padding-top: 10px; padding-bottom: 8px; flex-shrink: 0; }
.pub-sec .card-head h3 { font-size: 13px; white-space: nowrap; }
.pub-head h3 { flex: 1; min-width: 0; }
.pub-count { font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); border-radius: 20px; padding: 2px 9px; flex-shrink: 0; }
.pub-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.pub-list::-webkit-scrollbar { width: 6px; }
.pub-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }
.pub-empty { display: flex; align-items: center; gap: 9px; color: var(--faint); font-size: 12px; padding: 14px 2px; }
.pub-empty svg { width: 16px; height: 16px; flex-shrink: 0; }

/* корзина удалённых публикаций (модалка на вкладке «Публикации») */
.trash-list { display: flex; flex-direction: column; gap: 8px; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); }
.trash-item .grow { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.trash-item b { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.trash-item > .grow > span { font-size: 11px; color: var(--faint); }
.trash-item .ti-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* карточка-строка в колонке списка */
.pub-row { display: flex; flex-direction: column; gap: 5px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; flex-shrink: 0; }
.pub-row:hover { border-color: var(--accent); }
.pr-meta { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; color: var(--faint); }
/* корзина в строке списка: скрыта до наведения, чтобы не спорить с кликом по строке */
.pr-del {
  margin-left: auto; width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--faint); background: transparent;
  border: 1px solid transparent; cursor: pointer; transition: .15s; opacity: 0;
}
.pub-row:hover .pr-del, .pr-del:focus-visible { opacity: 1; }
.pr-del:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.pr-del svg { width: 14px; height: 14px; }
.pr-time { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.pr-ok { display: grid; place-items: center; color: var(--success); }
.pr-ok svg { width: 13px; height: 13px; }
.pub-row .pr-tg { width: 26px; height: 26px; color: var(--faint); flex-shrink: 0; font-size: 8px; font-weight: 800; }
.pub-row .pr-tg:hover { color: var(--accent-2); }
.pub-row .pr-tg svg { width: 15px; height: 15px; }
.pub-row .pr-err { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--danger); }
.pub-row .pr-err svg { width: 13px; height: 13px; flex-shrink: 0; }
/* пост, не сумевший выйти вовремя: красноватая рамка строки и подпись */
.pub-row.overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.pr-late { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--danger); }
.pr-late svg { width: 13px; height: 13px; flex-shrink: 0; }

/* плашка «не смог выйти вовремя» в редакторе */
.overdue-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.overdue-banner .ob-ic { color: var(--danger); flex-shrink: 0; }
.overdue-banner .ob-ic svg { width: 22px; height: 22px; }
.overdue-banner .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.overdue-banner b { font-size: 13px; }
.overdue-banner span { font-size: 12px; color: var(--muted); }
.profile-banner { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.profile-banner .ob-ic { color: var(--warn); }
.pub-row b { font-size: 12.5px; line-height: 1.35; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pub-row .net-dots { margin-top: 1px; }
.pub-row .nd { width: 19px; height: 19px; font-size: 8px; border-radius: 6px; }


/* редактор: расписание после утверждения */
.pub-lock { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 11px 13px; }
.pub-lock svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--faint); }
.pub-state { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.cal-side .card { margin-bottom: 16px; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend div { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3.5px; }

/* форма публикации в модалке */
.post-form { display: grid; gap: 15px; }
.pf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.net-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.net-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px;
  background: var(--surface-3); border: 1.5px solid var(--border); font-size: 13px; font-weight: 600;
  color: var(--muted); transition: .15s;
}
.net-pill i { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; font-size: 8px; font-style: normal; font-weight: 800; color: #fff; }
.net-pill:hover { border-color: var(--border-strong); color: var(--text); }
.net-pill.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.status-pick { display: flex; gap: 8px; }
.status-opt { flex: 1; padding: 9px; border-radius: 11px; background: var(--surface-3); border: 1.5px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: center; transition: .15s; }
.status-opt:hover { color: var(--text); }
.status-opt.on-draft { border-color: var(--faint); color: var(--text); }
.status-opt.on-ready { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.status-opt.on-published { border-color: var(--success); color: var(--success); background: var(--success-bg); }

/* ============================================================
   СОЦСЕТИ
   ============================================================ */
/* Соцсети: та же единая панель, что у AI-моделей — слева список сетей,
   справа настройка выбранной (классы каркаса .models-layout/.models-list общие) */
.net-detail .net-dhead { display: flex; align-items: center; gap: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.net-detail .net-dhead .grow { flex: 1; min-width: 0; }
.net-detail .net-dhead b { font-size: 15.5px; display: block; letter-spacing: -.01em; }
.net-detail .net-dhead span { font-size: 12.5px; color: var(--muted); }
.net-dbody { display: grid; gap: 12px; }
.net-dfoot { display: flex; align-items: center; gap: 9px; padding-top: 14px; border-top: 1px dashed var(--border); }
.net-dfoot .grow { flex: 1; }
.net-dfoot .btn-danger { padding-left: 12px; padding-right: 12px; }

/* ============================================================
   AI-МОДЕЛИ
   ============================================================ */
/* AI-модели: единая панель — полоса вкладок сверху, слева список провайдеров,
   справа настройка выбранного */
.models-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); grid-template-rows: auto 1fr; padding: 0; overflow: hidden; }
.models-tabs { grid-column: 1 / -1; display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.models-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--muted); background: none; cursor: pointer; transition: .15s;
}
.models-tab:hover { color: var(--text); background: var(--surface-2); }
.models-tab.on { color: var(--accent); background: var(--accent-soft); }
.models-tab svg { width: 15px; height: 15px; }
.models-tab .cnt { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--surface-3); color: var(--muted); }
.models-tab.on .cnt { background: var(--surface); color: var(--accent); }
.models-list {
  display: flex; flex-direction: column; gap: 2px; padding: 10px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
.models-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid transparent;
  background: none; cursor: pointer; text-align: left; transition: .15s;
}
.models-item:hover { background: var(--surface-2); }
.models-item.on { border-color: var(--accent); background: var(--accent-soft); }
.models-item .grow { flex: 1; min-width: 0; }
.models-item b { display: block; font-size: 14px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.models-detail { padding: 18px 20px 20px; min-width: 0; }
/* карточка настройки живёт внутри общей панели — своя рамка и старые отступы не нужны */
.model-card { display: flex; flex-direction: column; transition: .2s; }
.models-detail .model-card { border: 0; background: none; box-shadow: none; }
.models-detail .model-card:hover { transform: none; }
.models-detail .mc-head { padding: 0 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.models-detail .mc-body { padding: 0; }
.models-detail .mc-foot { padding: 14px 0 0; }
.models-detail .mc-foot .btn { flex: 0 0 auto; min-width: 140px; }
.models-detail .mc-body .adv-toggle + .mc-params { margin-bottom: 4px; }
@media (max-width: 940px) {
  .models-layout { grid-template-columns: 1fr; grid-template-rows: none; }
  .models-list { border-right: 0; border-bottom: 1px solid var(--border); }
}
.model-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.model-card .mc-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px 6px; }
.model-card .mc-head .grow { flex: 1; min-width: 0; }
.model-card .mc-head b { display: block; font-size: 14.5px; letter-spacing: -.01em; }
.model-card .mc-head span { font-size: 12px; color: var(--muted); }
.model-card .mc-body { padding: 0 16px 10px; display: grid; gap: 8px; flex: 1; }
.model-card .mc-foot { display: flex; gap: 9px; padding: 0 16px 10px; }
.model-card .mc-foot .btn { flex: 1; }
.model-card .mc-params { display: grid; gap: 8px; padding-top: 3px; border-top: 1px dashed var(--border); margin-top: 3px; padding-top: 10px; }
.param-row label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.adv-toggle { font-size: 12.5px; color: var(--faint); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.adv-toggle:hover { color: var(--muted); }
.adv-toggle svg { width: 15px; height: 15px; flex-shrink: 0; }
.input-eye svg { width: 18px; height: 18px; }
.theme-opt .tp-name svg { width: 16px; height: 16px; }
.radio-card b svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ============================================================
   АГЕНТЫ
   ============================================================ */
.agents-layout { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.agent-list { display: flex; flex-direction: column; gap: 7px; }
.agent-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--border); text-align: left; transition: .16s; width: 100%;
}
.agent-item:hover { border-color: var(--border-strong); }
.agent-item.active { border-color: var(--accent); background: var(--accent-soft); }
.agent-item .ai-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.agent-item .ai-ic svg { width: 17px; height: 17px; color: #fff; }
.agent-item .ai-main { flex: 1; min-width: 0; display: grid; gap: 3px; justify-items: start; }
.agent-item .ai-main b { font-size: 13px; line-height: 1.2; white-space: nowrap; }
.agent-item .ai-state { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.agent-item .ai-state.on { background: var(--success); box-shadow: 0 0 8px var(--success); }

.agent-item.lead { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.lead-tag { font-style: normal; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; line-height: 1.5; }
.autonomy-note { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--muted); padding: 9px 12px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 11px; line-height: 1.45; }
.autonomy-note svg { width: 15px; height: 15px; color: var(--faint); flex-shrink: 0; margin-top: 2px; }
.models-hint { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--warn); white-space: nowrap; }
/* кнопка копирования внутри блока редактирования системного промпта:
   правый нижний угол, полупрозрачная, проявляется при наведении */
.pr-text-wrap { position: relative; }
.models-hint svg { width: 14px; height: 14px; flex-shrink: 0; }
.models-hint a { font-weight: 600; }
.ag-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.agent-detail { display: grid; gap: 14px; }
.chat-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-wrap { position: relative; }
.chat-wrap.drag-files { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 6px; }
.chat-wrap.drag-files::after {
  content: "Отпустите, чтобы прикрепить изображение";
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; pointer-events: none; border-radius: 6px;
}
.ad-head { display: flex; align-items: flex-start; gap: 13px; }
.ad-head .ad-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; }
.ad-head .ad-ic svg { width: 21px; height: 21px; color: #fff; }
.ad-head .grow { flex: 1; }
.ad-head h3 { font-size: 17px; letter-spacing: -.02em; }
.ad-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
/* в карточке промпта заголовок — с начала строки: иконка-квадрат убрана */
.pr-detail .ad-head-ad-ic, .pr-detail .ad-head .ad-ic { display: none; }
.pr-detail .ad-head { gap: 0; }
.form-rows { display: grid; gap: 12px; }
.fr-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--border); cursor: pointer; transition: .15s; }
.radio-card:hover { border-color: var(--border-strong); }
.radio-card b { display: flex; align-items: center; gap: 7px; font-size: 13px; margin-bottom: 3px; }
.radio-card b svg { width: 14px; height: 14px; color: var(--muted); }
.radio-card span { font-size: 11.5px; color: var(--muted); line-height: 1.45; display: block; }
.radio-card.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-card.on b { color: var(--accent); }
.radio-card.on b svg { color: var(--accent); }

/* чат с агентом */
.chat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 8px; border-bottom: 1px solid var(--border);
}
.chat-head .tile { width: 36px; height: 36px; border-radius: 11px; font-size: 13px; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head b { font-size: 15px; letter-spacing: -.01em; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 11px; min-height: 220px; }
.msg { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: 12px; font-family: inherit; }
.msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--surface-3); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg .msg-tag { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 3px; }
.msg .msg-tag i { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
/* копирование сообщения: кнопка всплывает при наведении. Стоит на краю пузыря —
   снаружи, чтобы не закрывать текст, но с заходом внутрь на 12px: иначе между
   пузырём и кнопкой остаётся зазор, и курсор, уходя с пузыря, гасит кнопку
   раньше, чем до неё дойдёт. Внутренняя часть попадает в отступ сообщения,
   поэтому текст не перекрывается */
.msg { position: relative; }
.msg-act {
  position: absolute; top: 4px; width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center; cursor: pointer; color: var(--faint);
  background: var(--surface-2); border: 1px solid var(--border);
  opacity: 0; pointer-events: none; transition: opacity .15s, color .15s, border-color .15s;
}
.msg-act svg { width: 13px; height: 13px; }
.msg.bot .msg-act { left: calc(100% - 12px); }
.msg.user .msg-act { right: calc(100% - 12px); }
.msg:hover .msg-act, .msg-act:focus-visible { opacity: 1; pointer-events: auto; }
.msg-act:hover { color: var(--text); border-color: var(--border-strong); }
/* отметка «скопировано» держится без наведения, пока гаснет */
.msg-act.is-done { opacity: 1; pointer-events: auto; color: var(--success); border-color: var(--success); }
/* Расход токенов по ходу. Всплывает по наведению, как кнопка копирования:
   человек обычно читает переписку, а считать расход начинают те, кому он
   нужен, — постоянная цифра в каждом пузыре только бы мешала. Подсказка с
   разбивкой — нативный title, чтобы не плодить ещё один поповер */
.msg-usage { position: absolute; bottom: 5px; right: 8px; display: inline-flex; align-items: center; gap: 3px; font-size: 10px; line-height: 1; color: var(--faint); font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none; transition: opacity .15s; }
.msg-usage svg { width: 10px; height: 10px; }
.msg:hover .msg-usage, .msg-usage:focus-visible { opacity: 1; }
/* в плашке служебной строки значок — обычный элемент ленты, а не накладка:
   сама плашка узкая, и абсолютное позиционирование ломало бы её ширину */
.sys-pill .msg-usage { position: static; opacity: 0; }
.sys-line:hover .msg-usage { opacity: 1; }
/* темная подложка сообщения: цифра должна читаться, а не сливаться */
.msg.user .msg-usage { color: rgba(255, 255, 255, .8); }
/* технические статусы в чате: компактные чипы по центру ленты */
.sys-line { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 94%; }
/* свёрнутая группа служебных плашек: «N действий агента — выполнено» */
.sys-group {
  align-self: center; display: inline-flex; align-items: center; gap: 8px;
  max-width: 94%; padding: 6px 12px; cursor: pointer;
  border: 1px dashed var(--border-strong); border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 12px;
  transition: .15s;
}
.sys-group:hover { border-color: var(--accent); color: var(--text); }
.sys-group b { font-weight: 600; color: var(--text); white-space: nowrap; }
.sys-group .sg-st { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sys-group .sg-st svg { width: 13px; height: 13px; color: var(--success); }
.sys-group .spin { width: 11px; height: 11px; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; }
.sys-group.err, .sys-group.err .sg-st svg { color: var(--danger); }
.sys-group > svg { width: 13px; height: 13px; opacity: .6; }
.sys-collapse { padding: 3px 10px; font-size: 11.5px; opacity: .75; gap: 5px; }
/* плашки действий с вызовом модели кликабельны: открывают размышления */
.sys-pill.dbg { cursor: pointer; }
.sys-pill.dbg:hover { border-color: var(--accent); }
.sys-pill.dbg:hover .sys-st { color: var(--accent); }
.sys-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex-wrap: wrap;
  padding: 5px 12px; border-radius: 12px; font-size: 11.5px; line-height: 1.5;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  max-width: 100%; overflow-wrap: anywhere;
}
/* длинный текст ошибки: перенос по строкам внутри подложки, ничего не вылезает */
.sys-pill .sys-st { text-align: left; }
.sys-ic { display: inline-flex; flex-shrink: 0; }
.sys-ic svg { width: 12px; height: 12px; }
.sys-tool { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text); }
.sys-tool b { font-weight: 650; }
.sys-tool code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px;
}
.sys-st { min-width: 0; }
.sys-pill .tool-dots { margin-left: 0; }
.sys-pill.k-ok { background: var(--success-bg); border-color: transparent; }
.sys-pill.k-ok .sys-ic { color: var(--success); }
.sys-pill.k-err { background: var(--danger-bg); border-color: transparent; }
.sys-pill.k-err .sys-ic { color: var(--danger); }
.sys-pill.k-warn { background: var(--warn-bg); border-color: transparent; }
.sys-pill.k-warn .sys-ic { color: var(--warn); }
.sys-pill.k-info .sys-ic { color: var(--faint); }
/* остановка по кнопке — не сбой, поэтому нейтральная плашка, как у подсказок */
.sys-pill.k-stop .sys-ic { color: var(--muted); }
.sys-pill.k-work { background: var(--accent-soft); border-color: transparent; }
.sys-pill.k-work .sys-ic { color: var(--accent); }
.sys-pill.k-work .sys-ic svg { animation: sys-spin 1.1s linear infinite; }
@keyframes sys-spin { to { transform: rotate(360deg); } }
.sys-resend {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 650;
  border-radius: 999px; padding: 5px 13px; cursor: pointer; transition: .15s;
}
.sys-resend:hover { color: var(--text); border-color: var(--accent); }
.sys-resend svg { width: 12px; height: 12px; }
.msg.typing { display: inline-flex; gap: 5px; align-items: center; padding: 15px 17px; }
.tool-dots { display: inline-flex; gap: 4px; margin-left: 2px; }
.tool-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.tool-dots i:nth-child(2) { animation-delay: .15s; }
.tool-dots i:nth-child(3) { animation-delay: .3s; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-6px); } }
.msg.cf-row { display: flex; flex-direction: column; gap: 8px; max-width: 88%; }
.msg.cf-row .cf-q { font-size: 13px; font-weight: 650; }
.msg.cf-row .cf-actions { display: flex; gap: 8px; }
.msg.cf-row .cf-actions button { border: 0; border-radius: 9px; padding: 7px 18px; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: .15s; }
.msg.cf-row .cf-yes { background: var(--grad); color: #fff; }
.msg.cf-row .cf-yes:hover { filter: brightness(1.1); }
.msg.cf-row .cf-no { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-strong) !important; }
.msg.cf-row .cf-no:hover { color: var(--danger); border-color: var(--danger) !important; }
.msg .cf-actions { display: flex; gap: 8px; }
/* список вариантов ответа на вопрос — колонкой, кнопки на всю ширину карточки */
.msg .cf-actions.cf-col { flex-direction: column; align-items: stretch; }
.msg .cf-actions.cf-col button { width: 100%; text-align: center; padding: 9px 14px; }
.msg .cf-actions button { border: 0; border-radius: 9px; padding: 7px 18px; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: .15s; }
.msg .cf-yes { background: var(--grad); color: #fff; }
.msg .cf-yes:hover { filter: brightness(1.1); }

.tool-list { display: flex; flex-direction: column; }
.tool-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 2px; border-top: 1px solid var(--border); }
.tool-row:first-child { border-top: 1px solid var(--border); }
.tool-row .tr-info { min-width: 0; flex: 1; }
.tool-row .tr-info b { font-size: 13px; display: inline-block; margin-right: 6px; }
/* плашка у действий, которые по умолчанию спрашивают подтверждение:
   удаление в корзину и публикация в соцсети. Стоит рядом с названием,
   чтобы не ломать перенос строки */
.tool-row .tr-info .tr-warn { font-style: normal; font-weight: 600; font-size: 10.5px; display: inline-block; padding: 1px 6px; border-radius: 6px; vertical-align: 1px; color: #ffd9a8; background: rgba(251, 191, 36, .16); border: 1px solid rgba(251, 191, 36, .35); }
.tool-row .tr-info span { font-size: 11.5px; color: var(--faint); display: block; margin-top: 1px; }
.tool-perm { display: flex; gap: 3px; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tool-perm button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 650; padding: 5px 10px; border-radius: 7px; cursor: pointer; transition: .15s; white-space: nowrap; }
.tool-perm button:hover { color: var(--text); }
.tool-perm button.on { background: var(--grad); color: #fff; }
.tool-instr-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 7px; border-radius: 7px; flex-shrink: 0; margin-left: 4px; }
.tool-instr-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-instr-btn.has { color: var(--accent); }
.tool-instr-btn svg { width: 14px; height: 14px; }
.tool-instr { padding: 0 2px 10px; }
.tool-instr textarea {
  width: 100%; resize: none; font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; outline: none;
}
.tool-instr textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-custom { display: flex; gap: 6px; width: 100%; margin-top: 2px; }
.ask-custom input {
  flex: 1; min-width: 0; font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; outline: none;
}
.ask-custom input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-custom button {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted);
  font-size: 12.5px; font-weight: 700; border-radius: 9px; padding: 7px 14px;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.ask-custom button:hover { color: var(--text); background: var(--surface-3); }
.chat-input { display: flex; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); }
.chat-input .attach-btn { width: 46px; height: 46px; border-radius: 13px; background: var(--surface-3); border: 1px solid var(--border); color: var(--muted); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.chat-input .attach-btn:hover { color: var(--text); border-color: var(--accent); }
.chat-input .attach-btn svg { width: 19px; height: 19px; }
.chat-attach-row { display: flex; gap: 8px; padding: 8px 16px 0; flex-wrap: wrap; }
/* кнопка «смотреть за действиями агента» в шапке чата: место занимает всегда,
   включается после первого действия оркестратора с публикацией */
/* кнопка «за агентом»: скрыта, пока агент ничего не делал; при появлении цели —
   компактный чип с глазом и подписью */
.follow-btn {
  width: auto; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; gap: 6px; padding: 0 10px;
  color: var(--accent); background: var(--accent-soft); border-color: var(--accent);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.follow-btn svg { width: 14px; height: 14px; }
.follow-btn span { line-height: 1; }
.follow-btn[hidden] { display: none !important; }
.attach-chip { position: relative; display: inline-flex; }
.attach-chip img { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.attach-chip button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; cursor: pointer; }
.attach-chip button svg { width: 10px; height: 10px; }
/* фрагменты поста, прикреплённые к сообщению чата */
.quote-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 7px 10px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.quote-chip .qc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-chip button { border: none; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; }
.quote-chip button:hover { color: var(--danger); }
.quote-chip button svg { width: 12px; height: 12px; }

/* плавающая панель над выделением в тексте публикации */
/* Перефразируемый фрагмент: подсветка и волна, которая по нему идёт.
/* Перефразируемый фрагмент: подсветка и волна, которая по нему идёт.
   Фон состоит из одного-единственного слоя-градиента, поэтому и размер,
   и позиция, и повтор задаются одним значением. Если перечислить их парами
   (как было раньше), лишние значения браузер отбросит, слой останется на
   нулевой позиции, а кадры анимации — пустыми: полоса стоит намертво.
   Полоса идёт быстро (1.1с), чтобы ожидание в десятки секунд не казалось
   зависанием: заливка видна всегда, волна отвечает, что процесс идёт */
.regen-frag {
  cursor: pointer; border-radius: 4px; padding: 0 2px;
  background-color: color-mix(in srgb, var(--accent) 20%, transparent);
  background-image: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--accent) 78%, transparent) 50%, transparent 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent);
  animation: regenShimmer 1.1s linear infinite;
}
@keyframes regenShimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}
/* Переписанный кусок после перефразирования: остаётся подсвеченным и выделенным,
   чтобы было видно, что именно изменилось. Подсветка живёт в отрисованном виде
   (там маркеры разметки съедены тегами и по смещениям выделение уезжает), обычное
   поле обходится штатным выделением */
.fresh-sel {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 4px; padding: 0 2px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.msg-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.chat-img { max-width: 200px; max-height: 150px; border-radius: 10px; cursor: zoom-in; display: block; }
.msg.user .chat-img { border: 1px solid rgba(255,255,255,.25); }
/* min-width:0 обязателен: без него поле ввода не сжимается ниже своей
   собственной ширины и выталкивает кнопку отправки за край панели */
.chat-input input { flex: 1; min-width: 0; padding: 11px 15px; border-radius: 13px; background: var(--input-bg); border: 1px solid var(--border); outline: none; }
.chat-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-input .send-btn { width: 46px; height: 46px; border-radius: 13px; background: var(--grad); color: #fff; display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow-glow); }
.chat-input .send-btn:hover { filter: brightness(1.1); }
.chat-input .send-btn svg { width: 19px; height: 19px; }
/* Пока агент отвечает, кнопка отправки превращается в остановку: тот же
   квадрат, но приглушённый фон — видно, что действие другое */
.chat-input .send-btn.is-stop {
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); box-shadow: none;
}
.chat-input .send-btn.is-stop:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); color: var(--danger); filter: none; }

/* ---------- промпты: список всех системных текстов и их переопределения ---------- */
.ag-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.ag-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .15s;
}
.ag-tab:hover { color: var(--text); border-color: var(--border-strong); }
.ag-tab svg { width: 15px; height: 15px; }
.ag-tab.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.prompts-layout { display: grid; grid-template-columns: 200px 280px minmax(0, 1fr); gap: 12px; align-items: start; }
.pr-groups { display: flex; flex-direction: column; gap: 4px; }
.pr-group {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid transparent; cursor: pointer; transition: .15s;
}
.pr-group:hover { background: var(--surface-3); }
.pr-group b { font-size: 13px; font-weight: 600; }
.pr-group span { font-size: 11.5px; color: var(--faint); }
.pr-group.on { background: var(--accent-soft); border-color: var(--accent); }
.pr-group.on b { color: var(--accent); }
.pr-list { display: flex; flex-direction: column; gap: 3px; padding: 8px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); }
.pr-list-head { font-size: 11.5px; color: var(--faint); line-height: 1.4; padding: 4px 8px 8px; }
.pr-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; text-align: left;
  background: transparent; border: 1px solid transparent; cursor: pointer; transition: .15s;
}
.pr-item:hover { background: var(--surface-3); }
.pr-item.on { background: var(--surface); border-color: var(--border-strong); }
.pr-item-name { font-size: 13px; flex: 1; min-width: 0; }
.pr-item.on .pr-item-name { font-weight: 600; }
.pr-new {
  display: flex; align-items: center; gap: 7px; margin-top: 4px; padding: 8px 10px; border-radius: 9px;
  border: 1px dashed var(--border-strong); color: var(--muted); font-size: 12.5px; cursor: pointer; transition: .15s;
}
.pr-new:hover { color: var(--accent); border-color: var(--accent); }
.pr-new svg { width: 13px; height: 13px; }
.pr-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.pr-detail { padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
/* карточка промпта растягивается до нижнего края окна (высоту задаёт JS),
   внутри — колонка: шапка → само поле (дорастает) → переменные → кнопки */
.pr-detail { display: flex; flex-direction: column; overflow: auto; }
.pr-detail > .field { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.pr-detail .pr-text-wrap { flex: 1 1 auto; display: flex; min-height: 0; }
.pr-detail .pr-text-wrap textarea#pr-text { flex: 1 1 auto; min-height: 260px; height: auto; }
/* нередактируемый системный текст (служебные строки) растёт так же */
.pr-detail > .field > .pr-sys-text { flex: 1 1 auto; min-height: 200px; overflow: auto; }
.pr-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; }
.pr-vars-label { font-size: 11.5px; color: var(--faint); }
.pr-var {
  padding: 3px 8px; border-radius: 7px; background: var(--surface-3); border: 1px solid var(--border);
  color: var(--muted); font-size: 11.5px; font-family: ui-monospace, Consolas, monospace; cursor: pointer; transition: .15s;
}
.pr-var:hover { color: var(--accent); border-color: var(--accent); }
.pr-sys-text {
  margin: 0; padding: 12px; border-radius: 10px; max-height: 300px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; line-height: 1.5; font-family: ui-monospace, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.pr-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.pr-actions .grow { flex: 1; }
.pr-hint { font-size: 11.5px; color: var(--faint); }
@media (max-width: 1180px) { .prompts-layout { grid-template-columns: 1fr; } }

/* ============================================================
   НАСТРОЙКИ
   ============================================================ */
.set-layout { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; max-width: 1100px; }
.set-avatar-row { display: flex; align-items: center; gap: 18px; }
.set-avatar-row .avatar { width: 64px; height: 64px; border-radius: 18px; font-size: 23px; }
.set-avatar-row .grow { flex: 1; }
.set-avatar-row h3 { font-size: 18px; }
.set-avatar-row p { color: var(--muted); font-size: 13.5px; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.theme-opt { border-radius: 15px; border: 2px solid var(--border); overflow: hidden; cursor: pointer; background: var(--surface-2); transition: .16s; }
.theme-opt:hover { border-color: var(--border-strong); }
.theme-opt.on { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.theme-prev { height: 62px; position: relative; }
.theme-opt[data-v="dark"] .theme-prev { background: #0a0d16; }
.theme-opt[data-v="dark"] .theme-prev::before { content: ""; position: absolute; left: 14px; top: 14px; width: 60px; height: 58px; border-radius: 8px; background: #161d33; }
.theme-opt[data-v="dark"] .theme-prev::after { content: ""; position: absolute; right: 14px; top: 22px; width: 80px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #7c5cff, #22d3ee); }
.theme-opt[data-v="light"] .theme-prev { background: #f2f4fb; }
.theme-opt[data-v="light"] .theme-prev::before { content: ""; position: absolute; left: 14px; top: 14px; width: 60px; height: 58px; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(23,32,58,.1); }
.theme-opt[data-v="light"] .theme-prev::after { content: ""; position: absolute; right: 14px; top: 22px; width: 80px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #6a4cf7, #0ea5e9); }
.theme-opt .tp-name { padding: 11px 14px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* ============================================================
   МОДАЛКИ / ТОСТЫ
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px;
  background: rgba(4, 7, 16, .62); backdrop-filter: blur(6px); animation: fadeIn .2s ease;
}
:root[data-theme="light"] .modal-overlay { background: rgba(23, 32, 58, .35); }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 60px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 22px;
  box-shadow: var(--shadow-lg); animation: modalIn .28s cubic-bezier(.3, 1.2, .4, 1);
}
.modal-lg { width: min(660px, 100%); }
.modal-xl { width: min(1120px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 0; }
.modal-head .grow { flex: 1; }
.modal-head h3 { font-size: 18px; letter-spacing: -.02em; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-head .tile { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }
.modal-x { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.modal-x svg { width: 17px; height: 17px; }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 0 24px 22px; }
.modal-foot .grow, .mp-foot .grow { flex: 1; }
.modal-foot .btn { min-width: 120px; flex: 0 0 auto; white-space: nowrap; }
.modal-foot .btn .spin { margin-right: 6px; }
/* фиксированная рамка модалки: шапка и футер не листаются, тело прокручивается
   внутри — нижняя панель с кнопками всегда на экране (мастер калибровки);
   высота берётся всегда полная, иначе шаги разной длины «дёргали бы» размер */
.modal.flex-fixed { display: flex; flex-direction: column; overflow: hidden; height: calc(100vh - 44px); }
.modal.flex-fixed .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal.flex-fixed .modal-foot { border-top: 1px solid var(--border); padding-top: 12px; flex: none; }

/* правый нижний угол: контейнер привязан к низу и растёт вверх;
   z-index выше модалей (.mp-overlay/.lightbox = 1000), чтобы тосты не проваливались под затемнение */
/* подсказка «какие промпты задействует кнопка ИИ»: плавающая плашка
   у кнопки; строки — промпты, ваш вариант помечен точкой-акцентом */
#ai-tip { position: fixed; z-index: 1300; max-width: 340px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 12px; line-height: 1.55; pointer-events: auto; }
#ai-tip .ai-tip-title { font-weight: 600; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); margin-bottom: 5px; }
#ai-tip .ai-tip-row { color: var(--muted); white-space: nowrap; padding: 3px 6px; margin: 0 -6px; border-radius: 6px; }
#ai-tip .ai-tip-row span { color: var(--faint); margin-left: 6px; }
/* строки-промпты — «кнопки»: под курсором подсвечиваются заметно */
#ai-tip .ai-tip-row.row-link { cursor: pointer; transition: background .12s ease, color .12s ease; }
#ai-tip .ai-tip-row.row-link:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
#ai-tip .ai-tip-row.row-link:hover span { color: var(--text); opacity: .7; }
#ai-tip .ai-tip-row::before { content: "—"; color: var(--faint); margin-right: 6px; }
#ai-tip .ai-tip-row.mod::before { content: "●"; color: var(--accent); }

/* ---------- вкладка «Сборка» (Агенты) ---------- */
.pl-lead { font-size: 12.5px; color: var(--faint); margin: 0 0 12px; }
.pl-layout { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.pl-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.pl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.pl-head b { font-size: 14px; display: block; }
.pl-head span { font-size: 11.5px; color: var(--faint); }
.pl-rows { display: flex; flex-direction: column; }
.pl-row { display: flex; align-items: center; gap: 11px; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.pl-row:last-child { border-bottom: 0; }
.pl-row.off .pl-name, .pl-row.off .pl-ic { opacity: .4; }
.pl-row.off .pl-name b { text-decoration: line-through; font-weight: 400; }
.pl-ic { color: var(--faint); flex: none; display: flex; }
.pl-ic svg { width: 15px; height: 15px; }
.pl-name { flex: 1; min-width: 0; }
.pl-name b { display: block; font-size: 13px; font-weight: 500; }
.pl-name span { display: block; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-ctl { display: flex; align-items: center; gap: 3px; flex: none; }
.pl-btn { display: flex; padding: 5px; border: 0; background: transparent; color: var(--faint); cursor: pointer; border-radius: 7px; transition: background .12s, color .12s; }
.pl-btn:hover { background: var(--surface-3); color: var(--text); }
.pl-btn.danger:hover { color: var(--danger); }
.pl-btn svg { width: 14px; height: 14px; }
/* мини-переключатель включённости блока */
.pl-switch { position: relative; width: 34px; height: 19px; border-radius: 10px; border: 0; background: var(--surface-3); cursor: pointer; transition: background .15s; margin-left: 5px; flex: none; }
.pl-switch i { position: absolute; top: 2.5px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s; }
.pl-switch.on { background: var(--accent); }
.pl-switch.on i { left: 17px; }
.pl-foot { display: flex; gap: 8px; padding: 11px 16px 13px; }
/* диалог добавления блока */
.pl-pick { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; min-width: 380px; }
.pl-pick-head { font-size: 10.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); padding: 10px 4px 4px; }
.pl-pick-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; transition: background .12s; }
.pl-pick-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pl-pick-item b { font-size: 13px; font-weight: 500; color: var(--text); }
.pl-pick-item span { font-size: 11.5px; color: var(--faint); }
.pl-pick-item.used { opacity: .42; pointer-events: none; }
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 1100; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 10px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 16px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.3, 1.2, .4, 1); font-size: 13.5px;
}
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
.toast .t-ic { width: 21px; height: 21px; flex-shrink: 0; border-radius: 7px; display: grid; place-items: center; }
.toast .t-ic svg { width: 13px; height: 13px; }
.toast.ok .t-ic { background: var(--success-bg); color: var(--success); }
.toast.err .t-ic { background: var(--danger-bg); color: var(--danger); }
.toast.info .t-ic { background: var(--accent-soft); color: var(--accent); }
.toast b { display: block; font-size: 13.5px; }
.toast span { color: var(--muted); font-size: 12.5px; }

/* ============================================================
   ПРЕДПРОСМОТР ПУБЛИКАЦИИ (мокапы платформ, всегда светлые)
   ============================================================ */
.pv-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pv-tab { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted); transition: .15s; }
.pv-tab i { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; font-style: normal; font-size: 8px; font-weight: 800; color: #fff; }
.pv-tab:hover { color: var(--text); }
.pv-tab.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* колонка платформ справа от превью в редакторе */
.ed-pv-wrap { position: relative; padding-right: 46px; min-height: 440px; }
.ed-pv-wrap .pv { max-width: 380px; }
#ed-pv-stage { display: flex; justify-content: center; min-width: 0; }
.pv-legend { font-size: 11.5px; color: var(--muted); margin: 0 18px 12px; }
.ed-pv-head { border-bottom: none; padding-bottom: 4px; }
.pv-rail { position: absolute; top: 0; right: 0; display: flex; flex-direction: column; gap: 6px; }
.pv-rail-btn { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); display: grid; place-items: center; transition: .15s; }
.pv-rail-btn i { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-style: normal; font-size: 8.5px; font-weight: 800; }
.pv-rail-btn.on { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.pv-rail-btn:not(:disabled):hover { border-color: var(--border-strong); }
.pv-rail-btn:disabled { cursor: default; opacity: .45; }

.pv-stage { display: flex; justify-content: center; padding: 4px 0 2px; }
.pv { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; box-shadow: 0 10px 34px rgba(15, 23, 42, .22); overflow: hidden; color: #0f1419; font-size: 14px; line-height: 1.45; }
.pv-pad { padding: 14px 16px; }
.pv-text { white-space: pre-wrap; }
.pv-muted { color: #8b98a5; }
.pv-av { display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #7c5cff, #22d3ee); color: #fff; font-weight: 700; width: 40px; height: 40px; font-size: 14px; flex-shrink: 0; }
.pv-av.sm { width: 32px; height: 32px; font-size: 12px; }
.pv-av.ring { border: 2px solid #fff; box-shadow: 0 0 0 2.5px #d6249f; }
.pv-media { position: relative; display: grid; place-items: center; gap: 5px; aspect-ratio: 16/10; color: rgba(255, 255, 255, .95); }
.pv-media-group { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.pv-media-group .pv-media { aspect-ratio: 1/1; border-radius: 8px; }
.pv-media.sq { aspect-ratio: 1/1; }
.pv-media.tall { aspect-ratio: 2/3; }
.pv-media b { font-size: 40px; font-weight: 800; opacity: .9; text-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.pv-media span { font-size: 12px; display: inline-flex; gap: 6px; align-items: center; opacity: .9; }
.pv-media span svg { width: 14px; height: 14px; }

/* Telegram */
/* Telegram — тёмная тема, максимально близко к приложению */
.pv-tg { background: #0e0e10; border-radius: 14px; padding: 14px; }
.pv-tg-card { background: #212121; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.pv-tg-head { padding: 10px 14px 8px; }
.pv-tg-head b { font-size: 15px; color: #ee5b8e; letter-spacing: .01em; }
.pv-tg-card .pv-media { border-radius: 0; aspect-ratio: 4/5; }
.pv-tg-card .pv-media-group { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.pv-tg-card .pv-media-group .pv-media { aspect-ratio: 1/1; border-radius: 0; }
.pv-tg-body { padding: 8px 14px 10px; }
.pv-tg .pv-text { color: #f2f2f2; font-size: 15px; line-height: 1.32; white-space: pre-wrap; }
.pv-tg-tag { color: #62bcf9; }
.pv-tg-meta { display: flex; justify-content: flex-end; gap: 12px; align-items: center; margin-top: 6px; color: #aaaaaa; font-size: 12px; }
.pv-tg-meta svg { width: 14px; height: 14px; vertical-align: -2px; }
.pv-tg-meta span:first-child { display: inline-flex; align-items: center; gap: 3px; }

/* VK / Facebook / OK / Дзен */
.pv-feed-head { display: flex; gap: 10px; align-items: center; }
.pv-feed-head b { display: block; font-size: 14.5px; }
.pv-feed-head i { font-style: normal; color: #8b98a5; font-size: 12.5px; display: inline-flex; gap: 4px; align-items: center; }
.pv-feed-head i svg { width: 11px; height: 11px; }
.pv .pv-text + .pv-media, .pv-feed-head + .pv-text { margin-bottom: 10px; }
.pv .pv-media { border-radius: 10px; }
.pv-feed-actions { display: flex; gap: 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #edf0f3; color: #65778b; font-size: 12.5px; font-weight: 600; flex-wrap: wrap; }
.pv-feed-actions span { display: inline-flex; gap: 6px; align-items: center; }
.pv-feed-actions svg { width: 15px; height: 15px; }
.pv-fb-react { display: flex; justify-content: flex-end; align-items: center; margin-top: 10px; color: #65778b; font-size: 12.5px; }
.pv-fb-react span { display: inline-flex; gap: 4px; align-items: center; background: #e7f3ff; color: #1877F2; border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.pv-fb-react svg { width: 12px; height: 12px; }
.pv-dzen-src { color: #8b98a5; font-size: 12.5px; margin-bottom: 6px; }
.pv-dzen-title { font-size: 17px; line-height: 1.3; margin-bottom: 10px; }

/* Instagram */
.pv-ig-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; }
.pv-ig-head b { font-size: 13.5px; flex: 1; }
.pv-ig-dots { color: #262626; letter-spacing: 2px; font-weight: 700; }
.pv-ig-actions { display: flex; gap: 14px; align-items: center; padding: 10px 14px 4px; }
.pv-ig-actions svg { width: 22px; height: 22px; }
.pv-ig-actions .grow { margin-left: auto; }
.pv-ig-likes { padding: 6px 14px 2px; font-weight: 600; font-size: 13.5px; }
.pv-ig-cap { padding: 4px 14px; font-size: 13.5px; }
.pv-ig-cap b { margin-right: 6px; }
.pv-ig-tags { color: #00376b; }
.pv-ig-time { padding: 8px 14px 14px; text-transform: uppercase; font-size: 10.5px; letter-spacing: .08em; color: #8b98a5; }

/* Threads */
.pv-th-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.pv-th-head b { font-size: 14.5px; }
.pv-th-head span { color: #8b98a5; font-size: 13px; }
.pv-th-actions { display: flex; gap: 20px; margin-top: 12px; color: #65778b; }
.pv-th-actions svg { width: 17px; height: 17px; }

/* TikTok / YouTube Shorts */
.pv.pv-short { max-width: 240px; background: transparent; box-shadow: none; }
.pv-short-video { position: relative; aspect-ratio: 9/16; border-radius: 18px; overflow: hidden; display: flex; align-items: flex-end; color: #fff; background: linear-gradient(160deg, #1b1e28, #0d0f16); box-shadow: 0 10px 34px rgba(15, 23, 42, .3); }
.pv-play { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .16); backdrop-filter: blur(3px); display: grid; place-items: center; }
.pv-play svg { width: 20px; height: 20px; color: #fff; margin-left: 3px; }
.pv-short-rail { position: absolute; right: 10px; bottom: 84px; display: grid; gap: 13px; justify-items: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.pv-short-rail span { display: grid; justify-items: center; gap: 3px; }
.pv-short-rail svg { width: 24px; height: 24px; }
.pv-short-cap { padding: 12px 14px; font-size: 12.5px; line-height: 1.4; text-shadow: 0 1px 5px rgba(0, 0, 0, .65); }
.pv-short-cap b { display: block; margin-bottom: 3px; }
.pv-short-music { display: flex; gap: 6px; align-items: center; margin-top: 7px; opacity: .92; font-size: 11.5px; }
.pv-short-music svg { width: 12px; height: 12px; }
.pv-yt-top { position: absolute; top: 0; left: 0; right: 0; padding: 12px 14px; display: grid; gap: 3px; background: linear-gradient(180deg, rgba(0, 0, 0, .55), transparent); }
.pv-yt-top b { color: #fff; font-size: 14px; }
.pv-yt-top span { color: rgba(255, 255, 255, .92); font-size: 12px; }

/* Pinterest */
.pv.pv-pin { max-width: 250px; }
.pv-pin .pv-media { border-radius: 18px; margin: 12px 12px 0; }
.pv-pin-title { font-weight: 700; padding: 10px 14px 2px; font-size: 14px; }
.pv-pin-src { color: #8b98a5; font-size: 12.5px; padding: 2px 14px 14px; display: flex; justify-content: space-between; align-items: center; }

/* X */
.pv-x { display: flex; gap: 12px; padding: 14px 16px; }
.pv-x-head { font-size: 14.5px; }
.pv-x-head span { color: #8b98a5; font-weight: 400; font-size: 13.5px; }
.pv-x-body { flex: 1; min-width: 0; }
.pv-x-body .pv-media { margin-top: 8px; }
.pv-x-actions { display: flex; gap: 28px; margin-top: 12px; color: #65778b; font-size: 12.5px; }
.pv-x-actions span { display: inline-flex; gap: 6px; align-items: center; }
.pv-x-actions svg { width: 15px; height: 15px; }

/* ============================================================
   РЕДАКТОР ПУБЛИКАЦИИ (этапы: тема → текст → медиа)
   ============================================================ */
.editor-layout {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 14px; align-items: stretch;
  /* высота экрана минус шапка и паддинги контента:
     центральный блок (с панелью завершения) и предпросмотр — во всю высоту */
  height: calc(100vh - var(--topbar-h, 56px) - 46px);
}
.editor-stages {
  display: grid; gap: 12px; min-width: 0; align-content: start;
  overflow-y: auto; overflow-x: hidden; padding-right: 6px;
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.editor-stages::-webkit-scrollbar, .editor-side::-webkit-scrollbar { width: 6px; }
.editor-stages::-webkit-scrollbar-track, .editor-side::-webkit-scrollbar-track { background: transparent; }
.editor-stages::-webkit-scrollbar-thumb, .editor-side::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
.editor-stages::-webkit-scrollbar-thumb:hover, .editor-side::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
.editor-side {
  min-width: 0; overflow-y: auto; overflow-x: hidden; padding-right: 2px;
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
/* ---------- финальный блок редактора: действие · пояснение · отправка ----------
   Вертикальный стек: колонка редактора узкая (открытый чат забирает
   остальное), и рядом влезает только действие с пояснением. Корзина живёт
   в строке действия, справа от основной кнопки. */
.editor-finish { margin-top: 14px; }
.editor-finish-row { display: block; }
.editor-finish {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2);
}
/* строка действия: основная кнопка тянется, корзина прижата вправо */
.ef-top { display: flex; align-items: center; gap: 10px; }
.ef-action { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.ef-action > * { flex-shrink: 0; }
/* корзина: квадратная, вровень с основной кнопкой, не переносится */
.ef-del { width: 44px; height: 44px; flex: 0 0 auto; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.ef-del svg { width: 18px; height: 18px; }
/* пояснение: текст переносится по словам, а не распирает блок */
.ef-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ef-info b { font-size: 14px; line-height: 1.35; }
.ef-info span { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
/* отправка: кнопки переносятся, но не сжимаются */
.ef-send { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.done-status { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.done-send { white-space: nowrap; }

/* карточка этапа, над которой работает агент из чата: блокирована и подсвечена */
.card.stage { position: relative; }
.card.stage.agent-busy { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.agent-busy .stage-body, .agent-busy .stage-actions { pointer-events: none; opacity: .55; user-select: none; }
.agent-busy-tag {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent);
}
.agent-busy-tag .spin { width: 12px; height: 12px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; }

/* кнопка «План» в шапке чата: появляется вместе с задачей, показывает прогресс */
.plan-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px;
  border-radius: 9px; border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.plan-btn svg { width: 13px; height: 13px; }
.plan-btn[hidden] { display: none !important; }
/* выпадающий чек-лист плана: раскрывается поверх ленты, ничего не сдвигает */
.chat-plan {
  position: absolute; top: 52px; left: 12px; right: 12px; z-index: 10;
  max-height: min(320px, 50vh); overflow-y: auto; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.chat-plan[hidden] { display: none; }

/* История чатов: список выезжает из шапки, поиск сверху, новый чат снизу.
   Панель — это список известных разговоров, а не отдельный экран: остаться
   в разговоре и переключиться — одно движение */
/* Значок с числом чатов на кнопке в шапке: одна переписка — прячем,
   несколько — показываем, чтобы список не выглядел пустым */
#chat-chats-btn { position: relative; }
#chat-chats-btn svg { width: 16px; height: 16px; }
.chat-badge {
  position: absolute; top: 2px; right: 1px; min-width: 14px; height: 14px;
  padding: 0 3px; border-radius: 7px; background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 14px; text-align: center;
}
.chat-badge[hidden] { display: none; }
.chats-panel {
  position: absolute; top: 52px; right: 12px; z-index: 12;
  width: min(320px, calc(100% - 24px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.chats-panel[hidden] { display: none; }
.chats-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.chats-search svg { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.chats-search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  color: var(--text); font-size: 13.5px; font-family: inherit;
}
.chats-search input::placeholder { color: var(--text-3); }
.chats-list { max-height: min(340px, 50vh); overflow-y: auto; padding: 6px; }
.chat-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 4px 6px 4px 10px; border-radius: 10px;
}
.chat-row:hover { background: var(--surface-2); }
.chat-row.is-active { background: var(--accent-soft); }
.chat-row.is-active .cr-title { color: var(--accent); font-weight: 600; }
/* сама строка — кнопка: открыть чат можно в любом месте, а не только по
   названию, и клавиатурой это тоже работает */
.cr-open {
  flex: 1; min-width: 0; display: grid; gap: 1px; padding: 6px 0;
  border: 0; background: transparent; text-align: left; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.cr-title {
  font-size: 13.5px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cr-meta { font-size: 11.5px; color: var(--text-3); }
.cr-act { display: flex; align-items: center; gap: 1px; flex: none; }
.cr-btn {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-3); cursor: pointer;
}
.cr-btn:hover { background: var(--surface-3); color: var(--text); }
.cr-btn svg { width: 14px; height: 14px; }
.cr-del:hover { color: var(--danger); }
.chats-empty { padding: 14px 12px; font-size: 13px; color: var(--text-3); text-align: center; }
/* Подсказка с полным названием чата: в строке текст обрезан, а узнать,
   что за чат, по «Придумай пять тем для постов про…» нельзя */
.chats-tip {
  position: fixed; z-index: 60; max-width: min(380px, calc(100vw - 24px));
  padding: 8px 11px; border-radius: 10px;
  background: var(--text); color: var(--surface);
  font-size: 12.5px; line-height: 1.35;
  box-shadow: var(--shadow-lg); pointer-events: none;
  animation: tip-in .12s ease-out;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.chats-new {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--accent); font-size: 13.5px;
  font-weight: 600; font-family: inherit; cursor: pointer;
}
.chats-new:hover { background: var(--surface-2); }
.chats-new svg { width: 15px; height: 15px; }
.msg.plan-msg { display: grid; gap: 6px; }
.plan-step {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.35;
}
.plan-step .ps-ic {
  width: 18px; height: 18px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--border-strong); color: #fff;
}
.plan-step .ps-ic svg { width: 11px; height: 11px; }
.plan-step .ps-text { flex: 1; min-width: 0; }
.plan-step .spin { width: 12px; height: 12px; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; flex-shrink: 0; }
.plan-step.done { opacity: .6; }
.plan-step.done .ps-text { text-decoration: line-through; }
.plan-step.done .ps-ic { background: var(--success); border-color: var(--success); }
.plan-step.cur { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.plan-step.cur .ps-ic { border-color: var(--accent); }
.plan-aborted { font-size: 11.5px; font-weight: 700; color: var(--warn); }
/* предупреждение после трёх остановок ИИ на одной задаче */
.plan-warn {
  display: grid; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--warn); border-radius: 10px; background: var(--warn-bg);
  font-size: 12.5px; color: var(--text);
}
.plan-warn .pw-actions { display: flex; gap: 8px; }
/* строка остановки с кнопкой «Возобновить» */
.plan-resume { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-resume .plan-aborted { flex: 1; min-width: 0; }
/* план закрыт завершением хода, а не самим агентом: спокойная пометка,
   чтобы это не читалось как отчёт модели о работе */
.plan-note { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); }
.plan-note svg { width: 11px; height: 11px; }

/* кнопка и окно отладки инструмента: промпты, размышления, ответ */
.debug-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10,12,20,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.debug-card { width: min(940px, 96vw); max-height: 90vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.debug-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.debug-body { overflow-y: auto; padding: 12px 16px 16px; display: grid; gap: 14px; font-size: 12.5px; }
.dbg-sec h4 { margin: 0 0 6px; font-size: 13px; }
.dbg-sec pre { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; line-height: 1.5; max-height: 40vh; overflow-y: auto; }
.dbg-msg { margin: 8px 0 0; }
.dbg-msg b { text-transform: uppercase; font-size: 10px; letter-spacing: .05em; color: var(--muted); }
.dbg-msg pre { margin-top: 3px; }
.dbg-live { color: var(--success); }
.dbg-empty { color: var(--faint); font-style: italic; }
.debug-body details summary { cursor: pointer; font-weight: 600; padding: 4px 0; color: var(--text); }
.done-status.ok { background: var(--success-bg); color: var(--success); }
.done-status.acc { background: var(--accent-soft); color: var(--accent); }
.btn-lg { padding: 12px 22px; font-size: 15px; }

/* кнопка «назад» в шапке (редактор публикации) */
.top-back { width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; }
.top-back svg { width: 17px; height: 17px; }

.stage { padding: 0; }
.stage-head { display: flex; align-items: center; gap: 11px; padding: 12px 16px 0; flex-wrap: wrap; }
.stage-num { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; font-size: 12.5px; font-weight: 800; background: var(--surface-3); color: var(--faint); border: 1px solid var(--border); flex-shrink: 0; }
.stage-head b { display: block; font-size: 14.5px; }
.stage-head span { font-size: 12.5px; color: var(--muted); }
/* управление справа в шапке (переключатель типа медиа) */
.stage-aside { flex: none; }
.stage-aside .seg { margin-bottom: 0; }
.stage-body { padding: 10px 16px 14px; }
.stage-actions { display: flex; align-items: center; gap: 8px; padding: 0 16px 14px; flex-wrap: wrap; }
.stage-actions > .grow { flex: 1; }
.stage-empty { font-size: 13px; color: var(--faint); margin: 0; padding: 4px 0 6px; }
/* правки текста: одна кнопка открывает модалку со всей библиотекой промптов */
.preset-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.preset-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 12.5px; line-height: 1.4; cursor: pointer; transition: .15s; white-space: nowrap;
}
.preset-chip svg { width: 13px; height: 13px; flex: none; }
.preset-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.preset-chip.btn-danger, .preset-chip.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.preset-chips.busy .preset-chip.btn-danger:hover { background: var(--danger); color: #fff; }
.preset-chips.busy .preset-chip { opacity: .45; pointer-events: none; }
.preset-chips.busy .preset-chip.btn-danger { opacity: 1; pointer-events: auto; }
/* тип промпта в диалоге: правка текста или проверка текста */
.sp-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-type {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; text-align: left;
}
.sp-type svg { width: 14px; height: 14px; }
.sp-type span { font-weight: 400; font-size: 12px; color: var(--faint); }
.sp-type:hover { border-color: var(--border-strong); }
.sp-type.on { border-color: var(--accent); background: var(--accent-soft); }
.sp-type.on span { color: var(--muted); }
/* панель «Размышления модели» в окне проверки: раскрывается пока модель думает,
   сворачивается, когда пошёл отчёт; вручную — клик по шапке */
.check-think {
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2);
  margin-bottom: 10px;
}
.check-think-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px;
  box-sizing: border-box; background: none; border: none; text-align: left;
  color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.check-think-head:hover { color: var(--text); }
.check-think-head .spin { width: 12px; height: 12px; }
.check-think-caret { margin-left: auto; display: grid; place-items: center; transition: transform .15s; }
.check-think-caret svg { width: 12px; height: 12px; }
.check-think.closed .check-think-caret { transform: rotate(-90deg); }
.check-think-body {
  max-height: 30vh; overflow-y: auto; padding: 0 12px 10px;
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
.check-think-body h4 { margin: 8px 0 3px; font-size: 12px; }
.check-think-body ul, .check-think-body ol { margin: 3px 0; padding-left: 18px; }
.check-think-body p { margin: 0 0 6px; }
/* отчёт проверки: плашка вердикта + текст отчёта */
.check-report-top { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.check-verdict {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.check-verdict svg { width: 14px; height: 14px; }
.check-verdict.pass { background: var(--success-bg); color: var(--success); }
.check-verdict.fail { background: var(--danger-bg); color: var(--danger); }
.check-verdict.none { background: var(--surface-3); color: var(--muted); }
.check-report { font-size: 14px; line-height: 1.55; max-height: 52vh; overflow-y: auto; }
.check-report h4 { margin: 12px 0 4px; font-size: 13.5px; }
.check-report h4:first-child { margin-top: 0; }
.check-report ul, .check-report ol { margin: 4px 0 8px; padding-left: 20px; }
.check-report li { margin: 3px 0; }
.check-report p { margin: 0 0 8px; }
.check-report p:last-child { margin-bottom: 0; }
.check-report table, .check-think-body table {
  border-collapse: collapse; width: 100%; margin: 6px 0 10px; font-size: 12.5px;
}
.check-report th, .check-report td, .check-think-body th, .check-think-body td {
  border: 1px solid var(--border); padding: 5px 8px; text-align: left; vertical-align: top;
}
.check-report th, .check-think-body th { background: var(--surface-3); font-weight: 600; }
/* модалка «Все промпты»: список строк с поиском, клик по строке — применить промпт;
   строки отсортированы по последнему использованию, справа — когда использован */
.pp-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; margin-top: 10px; }
.preset-row { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 10px; border-radius: 9px; cursor: pointer; }
.preset-row:hover { background: var(--surface-3); }
.preset-row-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-row-used { flex: none; font-size: 11.5px; color: var(--faint); margin: 0 4px; }
/* значок вердикта в списке отчётов проверок */
.cr-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none; margin-right: 6px;
  display: grid; place-items: center;
}
.cr-dot svg { width: 12px; height: 12px; }
.cr-dot.pass { background: var(--success-bg); color: var(--success); }
.cr-dot.fail { background: var(--danger-bg); color: var(--danger); }
.cr-dot.none { background: var(--surface-3); color: var(--muted); }
.preset-row-icon {
  width: 26px; height: 26px; padding: 0; border: none; background: transparent; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.preset-row-icon:hover { background: var(--surface-2); color: var(--text); }
.preset-row-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }
.preset-row-icon svg { width: 13px; height: 13px; }
.preset-empty { padding: 10px 12px; font-size: 12.5px; color: var(--faint); }
/* ---------- блок текста публикации ----------
   Одна рамка на весь блок: панель форматирования сверху, само поле, снизу
   служебные строки — счётчик знаков и объём текста. Счётчик живёт в рамке, а не
   поверх поля, поэтому не липнет к вертикальной полосе прокрутки. */
.ed-text-frame {
  border: 1px solid var(--border); border-radius: 12px; background: var(--input-bg);
  overflow: hidden; transition: border-color .18s, box-shadow .18s;
}
.ed-text-frame:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.ed-text-frame .fmt-bar { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
/* размеры бокса задаются здесь, иначе переключение «глазка» дёргает вёрстку */
.ed-text-frame .ed-text-box, .ed-text-frame .rich-text { height: 370px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.ed-text-frame .ed-text-box:focus-within, .ed-text-frame .rich-text:focus { border-color: transparent; box-shadow: none; }
/* поле с исходным текстом: настоящий textarea прозрачный, а сверху лежит слой
   с тем же текстом, где спецзнаки разметки серые. Рамка и фон — на обёртке,
   иначе рамка textarea дублировала бы рамку слоя */
.ed-text-box {
  position: relative; overflow: hidden;
}
.ed-text-frame .ed-text-box textarea, .ed-text-frame .ed-text-hl, .ed-text-frame .rich-text { padding: 10px 13px; }
.ed-text-box textarea {
  position: relative; z-index: 1; display: block; width: 100%; height: 100%;
  border: 0; background: transparent; color: transparent; caret-color: var(--text);
  word-break: break-word;
}
.ed-text-box textarea:focus { border-color: transparent; box-shadow: none; }
.ed-text-box textarea::placeholder { color: var(--faint); }
/* сценарий этапа 1: та же высота поля, что у текста поста */
.ed-outline-ta { height: 260px !important; min-height: 260px !important; resize: vertical; }
.ed-text-hl {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none; user-select: none; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.ed-text-hl .fmt-mark { color: var(--faint); }
/* набор через IME: составной текст поле рисует само и не должно быть прозрачным —
   на это время включаем обычный цвет и прячем слой */
.ed-text-box.ime textarea { color: var(--text); }
.ed-text-box.ime .ed-text-hl { visibility: hidden; }
/* редактируемый вид текста «как в посте»: тот же бокс, что у поля, но с отрисовкой */
.rich-text {
  width: 100%; overflow-y: auto;
  outline: none; font-size: inherit; line-height: inherit; white-space: pre-wrap; word-break: break-word; cursor: text;
}
.rich-text code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }
.fmt-bar { display: flex; align-items: center; gap: 3px; padding: 6px 8px; border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--surface-2); flex-wrap: wrap; }
.fmt-bar + .input-wrap { border-radius: 0 0 12px 12px; }
.fmt-bar button { width: 31px; height: 28px; padding: 0; display: grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--text); font-size: 14px; line-height: 1; cursor: pointer; transition: .15s; }
.fmt-bar button:hover { background: var(--surface-3); border-color: var(--border); }
.fmt-bar button:active { transform: translateY(1px); }
.fmt-bar .fmt-code { font-size: 10.5px; font-weight: 700; background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.fmt-bar .fmt-clear { color: var(--muted); }
.fmt-bar .fmt-clear svg, .fmt-bar .fmt-mode svg { width: 14px; height: 14px; }
.fmt-bar .fmt-mode.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.fmt-bar .fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
/* действия с выделением: «Перефразировать» и «В чат». Пока в тексте ничего
   не выделено, кнопки приглушены; с выделением подсвечиваются. Во время
   перефразирования кнопка растягивается и показывает статус с секундами —
   ждать 20–80 секунд молча нельзя, а повторное нажатие отменяет */
.fmt-bar .fmt-sel svg { width: 15px; height: 15px; }
.fmt-bar .fmt-sel[disabled] { opacity: .3; cursor: default; }
.fmt-bar .fmt-sel[disabled]:hover { background: transparent; border-color: transparent; }
.fmt-bar .fmt-sel.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.fmt-bar .fmt-sel.busy {
  width: auto; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-color: var(--accent);
  cursor: pointer; white-space: nowrap;
}
.fmt-bar .fmt-sel.busy .spin { width: 12px; height: 12px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; flex-shrink: 0; }
.fmt-bar .fmt-sec { color: var(--muted); font-variant-numeric: tabular-nums; }
/* служебные строки под полем: счётчик знаков, ниже — объём текста.
   Объём живёт здесь же, рядом со счётчиком: длина текста и её ограничение
   читаются одним блоком, а не двумя разрозненными полосами */
.ed-text-foot {
  display: grid; gap: 7px; padding: 8px 12px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.ed-len { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; line-height: 1.4; color: var(--faint); }
.ed-len svg { width: 13px; height: 13px; flex: none; margin-top: 2px; }
.ed-len.almost { color: var(--warn); }
.ed-len.warn { color: var(--danger); }
.len-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.len-ctrl-cap { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
/* слайдер объёма в стиле Blender: короткая полоса с делениями, драг меняет
   значение, клик без движения — ввод числа; рядом само число и его формат */
.blen-slider {
  position: relative; flex: none; width: 168px; height: 24px; border-radius: 8px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--border);
  cursor: ew-resize; user-select: none; touch-action: none;
}
.blen-slider::after {
  content: ""; position: absolute; left: 7px; right: 7px; bottom: 5px; height: 3px;
  background-image: repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 9px);
  opacity: .55; pointer-events: none;
}
.blen-fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  background: var(--accent-soft); transition: width .08s ease-out; pointer-events: none;
}
.blen-slider.dragging .blen-fill { transition: none; }
.blen-input {
  position: absolute; inset: 0; width: 100%; box-sizing: border-box; z-index: 2;
  text-align: center; background: var(--surface); border: none; outline: none;
  font-size: 12.5px; color: var(--text); padding: 0 8px;
  appearance: textfield; -moz-appearance: textfield;
}
.blen-input::-webkit-outer-spin-button, .blen-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.len-val { font-size: 13.5px; line-height: 1; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.len-ctrl.dragging .len-val { color: var(--accent); }
/* при вводе числа показываем его прямо в полосе — дублирующее число рядом убираем */
.len-ctrl.editing .len-val { visibility: hidden; }
.len-hint { font-size: 12px; line-height: 1; color: var(--accent); min-width: 66px; pointer-events: none; }
/* текст сверх максимального объёма: подсветка живёт в обоих видах поля —
   в слое с маркерами и в отрисованном, форматирование внутри сохраняется */
.over-limit { color: var(--warn); }
/* строка генерации: главное действие и промпты — одна переносимая строка,
   поэтому кнопка не висит отдельной полосой под всем блоком */
.ed-gen-row .ed-gen-btn { flex: none; }
/* окно «Варианты»: три текста с разными хуками стоят рядом — сравнивать
   первые фразы и объём на одной высоте удобнее, чем по очереди */
.variants { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: stretch; }
.variant { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.variant-head { display: flex; align-items: center; gap: 8px; }
.variant-head b { font-size: 13.5px; }
.variant-meta { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-size: 11.5px; color: var(--faint); }
.variant-meta svg { width: 13px; height: 13px; }
.variant-text {
  flex: 1; min-height: 200px; max-height: 46vh; overflow-y: auto;
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.variant-text code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; }
.variant-foot { display: flex; align-items: center; gap: 8px; }
.variant-len { display: inline-flex; align-items: center; gap: 5px; flex: 1; min-width: 0; font-size: 11.5px; color: var(--warn); }
.variant-len svg { width: 13px; height: 13px; }
.variant.is-failed { border-color: var(--danger); }
@media (max-width: 900px) {
  .variants { grid-template-columns: 1fr; }
  .variant-text { max-height: 30vh; }
}
/* меню идей автосбора: три темы раскладываются построчно из одного стрима,
   каждая карточка — кнопка: клик выбирает тему и продолжает сбор */
.tp-ideas { display: flex; flex-direction: column; gap: 8px; }
.idea-card {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13.5px;
  line-height: 1.4; cursor: pointer; transition: border-color .12s, background .12s;
}
.idea-card:hover:not(:disabled), .idea-card:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.idea-card:disabled { opacity: .75; cursor: default; }
.idea-wait { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); }
.idea-text { min-width: 0; word-break: break-word; }
/* display у классов перебивает скрытие атрибутом hidden — закрываем это явно */
.tp-ideas[hidden], .idea-wait[hidden], .idea-text[hidden] { display: none; }
/* ряд идей тем внутри блока «Тема и сценарий»: полоса-«складка» прячет/показывает
   карточки, длинный список листается скроллом */
.ed-idea-row { margin: 12px 0; }
.ed-idea-fold {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 7px 10px; border: 1px dashed var(--border); border-radius: 8px;
  background: transparent; color: var(--faint); font: inherit; font-size: 12.5px; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.ed-idea-fold:hover { color: var(--text); border-color: var(--accent); }
.ed-idea-fold .fold-arrow { display: inline-block; transition: transform .15s; }
.ed-idea-row.is-folded .fold-arrow { transform: rotate(-90deg); }
.ed-idea-row .tp-ideas { margin-top: 8px; max-height: 180px; overflow-y: auto; padding-right: 4px; }
.ed-idea-row.is-folded .tp-ideas { display: none; }
/* мастер калибровки: тело разбито на зоны — рельса статична и не листается
   вовсе, прокрутка живёт только в области содержимого, поэтому ничто не
   заезжает под сегменты; пройденные кликабельны, подписи — в подсказках */
.cal-modal .modal-body { overflow: hidden; padding: 0 0 16px; display: flex; flex-direction: column; }
.cal-rail { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; padding: 0 24px 10px; border-bottom: 1px solid var(--border); }
/* правый слот рельсы: единая модель ИИ для всех ИИ-действий калибровки */
.cal-rail-model { display: flex; flex-direction: column; gap: 4px; min-width: 200px; max-width: 280px; }
.cal-rail-model > span { font-size: 10.5px; letter-spacing: .3px; color: var(--faint); }
.cal-rail-model select { font-size: 12px; padding: 6px 10px; }
.cal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 24px 2px; }
.cal-seg { display: block; width: 100%; text-align: center; padding: 10px 12px; font-size: 13px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 12px; background: transparent; cursor: pointer; transition: border-color .15s, background .15s, color .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-seg:hover { border-color: var(--accent); }
.cal-seg.cur { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); }
.cal-seg.locked { opacity: .45; cursor: default; }
.cal-seg.locked:hover { border-color: var(--border-strong); }
/* вкладки третьего блока: Голос / Пункты / Промпт */
.cal-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.cal-tab { padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: 999px; background: transparent; font-size: 13px; color: var(--muted); cursor: pointer; }
.cal-tab.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 10%, transparent); }
/* складки статуса разбора под полями: компактно, без системного шума */
.cal-fold { margin-top: 6px; }
.cal-fold-btn { padding: 0; border: 0; background: transparent; font-size: 12px; color: var(--accent-2, var(--accent)); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.cal-fold-btn svg { width: 12px; height: 12px; flex: none; }
.cal-fold-btn i { color: var(--faint); font-style: normal; text-decoration: underline dotted; }
.cal-fold-btn.faint { color: var(--muted); }
.cal-fold-btn.cal-spin { color: var(--muted); }
.cal-fold-list { display: flex; flex-direction: column; margin-top: 6px; }
.cal-fold-list .cal-item { padding: 3px 0 3px 12px; }
/* строки разбора в формате «параметр: значение»: параметр — типовой,
   из набора, который сайт хранит и быстро читает (сайт, телефон, запрет…) */
.cal-item { display: flex; gap: 10px; align-items: baseline; padding: 5px 0 5px 12px; border-left: 2px solid var(--border-strong); color: var(--text); font-size: 13px; line-height: 1.45; }
.cal-item i { flex: none; min-width: 74px; font-size: 11px; color: var(--faint); font-style: normal; text-transform: lowercase; letter-spacing: .2px; }
.cal-item b { word-break: break-word; font-weight: 400; }
.cal-item.faint { color: var(--faint); border-left-style: dashed; display: block; }
/* индикация последовательного разбора блоков: спиннер на текущем блоке */
.cal-spinner { width: 11px; height: 11px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 6px; animation: calSpin .8s linear infinite; }
@keyframes calSpin { to { transform: rotate(360deg); } }
.cal-spin { animation: calPulse 1.2s ease-in-out infinite; }
@keyframes calPulse { 50% { opacity: .55; } }
/* кнопка пересборки в момент работы ИИ: спиннер вместо иконки,
   лёгкое дыхание кнопки — видно, что процесс не завис */
.cal-building { opacity: .8; animation: calBtnBreath 1.4s ease-in-out infinite; }
.cal-building .cal-spinner { margin-right: 6px; }
@keyframes calBtnBreath { 50% { opacity: .55; } }
/* строка автосбора в редакторе: селект агента + кнопка, без карточки-блока */
/* Верх блока редактирования: выбор агента, выбор уровня размышлений и кнопка
   сбора должны умещаться в одну строку. Строка не переносится, но элементы
   сжимаются по-разному: у каждого есть минимум, ниже которого подпись
   становится нечитаемой, — сначала режется самое длинное (имя провайдера),
   уровень размышлений держится твёрдо, кнопка сбора уступает последней */
.ed-auto-row { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.ed-auto-row .select-wrap { flex: 0 1 auto; min-width: 150px; max-width: 200px; }
.ed-auto-row select { width: 100%; text-overflow: ellipsis; }
.ed-auto-row .think-wrap { flex: 0 0 76px; min-width: 76px; }
.ed-auto-row [data-auto] { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* выбор уровня размышлений: у провайдера их ровно три, у неразмышляющих
   моделей блока нет вовсе. Размеры — как у соседнего выбора агента,
   иначе строка разъезжается по вертикали на пару пикселей */
.think-wrap .think-sel {
  padding: 9px 30px 9px 13px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.think-wrap .think-sel:hover { color: var(--text); border-color: var(--border-strong); }
/* блок медиа: рамка-дропзона с плитками, под ней — ряд источников с подписями */
.media-board {
  border: 1.5px dashed var(--border-strong); border-radius: 14px; padding: 10px;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
/* пустая рамка — зона для перетаскивания: подсказка по центру, достаточно высокая,
   чтобы в неё попасть, но не занимает полкарточки */
.media-board.is-empty { min-height: 104px; display: grid; place-items: center; padding: 16px; }
.media-board.drag-files { border-color: var(--accent); background: var(--accent-soft); }
.media-board-hint {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0; font-size: 13px; color: var(--faint); text-align: center;
}
.media-board-hint svg { width: 16px; height: 16px; flex-shrink: 0; }
/* плитки фиксированной ширины — не растягиваются на всю строку, когда файлов мало */
.media-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 112px)); gap: 8px; }
.media-tile { aspect-ratio: 4/5; border-radius: 12px; display: grid; place-items: center; gap: 4px; color: #fff; position: relative; }
.media-tile svg { width: 22px; height: 22px; opacity: .95; }
.media-tile span { font-size: 11px; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.media-tile .media-rm { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.media-tile:hover .media-rm, .media-tile:focus-within .media-rm { opacity: 1; }
.media-tile .media-rm svg { width: 12px; height: 12px; }
.media-tile .media-pen { top: 6px; left: 6px; right: auto; }
/* слот добавления: пунктирная заглушка в сетке, подсвечивается при наведении */
.media-tile.media-add { border: 1.5px dashed var(--border-strong); color: var(--muted); background: transparent; }
.media-tile.media-add:hover { border-color: var(--accent); color: var(--accent); }
.media-add[disabled] { opacity: .45; cursor: not-allowed; }
.media-tile.is-video .media-rm, .media-tile.is-video > svg { filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .45)); }
.media-tile[data-zoom] { cursor: zoom-in; }
.media-tile .media-pen { top: 6px; left: 6px; }
/* ряд источников под рамкой: подписанные кнопки в одну переносимую строку */
.ed-media-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* flex + margin:auto центрирует карточку, а когда та выше экрана — оверлей листается, ничего не отрезается */
.mp-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(2, 6, 23, .7); display: flex; overflow-y: auto; padding: 20px; }
.mp-card { width: min(480px, 94vw); margin: auto; display: flex; flex-direction: column; gap: 0; }
.mp-card .mc-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 4px; }
.mp-card .mc-head .grow { flex: 1; min-width: 0; }
.mp-card .mc-head b { display: block; font-size: 14.5px; }
.mp-card .mc-head span { font-size: 12px; color: var(--muted); }
.mp-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.mp-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.mp-check input { width: 15px; height: 15px; accent-color: var(--accent); }
.mp-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 14px; }
/* диалог поиска картинок: широкая карточка почти на весь экран, крупные плитки */
.rp-card { width: min(1200px, 95vw); }
.rp-card .mc-head span { font-size: 12px; color: var(--muted); }
/* высота сетки фиксированная: сколько бы картинок ни пришло на странице,
   окно поиска не меняет размер (лишнее листается внутри) */
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; padding: 12px 16px; height: 70vh; overflow-y: auto; }
/* на время запроса старые картинки остаются, но приглушаются — окно не меняет размер */
.rp-grid.loading { opacity: .45; pointer-events: none; }
/* заглушка пустой сетки до первого поиска */
.rp-empty {
  grid-column: 1 / -1; display: grid; place-items: center; gap: 10px; align-content: center;
  padding: 60px 20px; color: var(--faint); font-size: 13.5px; text-align: center;
}
.rp-empty svg { width: 26px; height: 26px; opacity: .6; }
/* листание результатов: назад / страница N из M / ещё 12 */
.rp-pager { display: flex; align-items: center; gap: 10px; padding: 10px 16px 0; }
.rp-pageinfo { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.rp-item { position: relative; aspect-ratio: 1/1; border-radius: 10px; overflow: hidden; cursor: pointer; border: 2px solid transparent; }
.rp-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rp-item.on { border-color: var(--accent); }
.rp-item.bad { display: none; }
/* подпись источника на плитке (название, автор · источник · лицензия):
   скрыта, проявляется при наведении на плитку */
.rp-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 7px 6px;
  opacity: 0; transition: opacity .15s;
  background: linear-gradient(transparent, rgba(2, 6, 23, .88)); color: #fff;
  font-size: 10.5px; line-height: 1.3; display: grid; gap: 1px; pointer-events: none;
}
.rp-cap b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-cap span { opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-item:hover .rp-cap, .rp-item:focus-within .rp-cap { opacity: 1; }
/* строка запроса в окне поиска картинок: крупное поле + квадратная кнопка-лупа справа */
.wi-row { display: flex; gap: 8px; align-items: stretch; padding: 12px 16px 0; }
.wi-query-wrap { flex: 1; min-width: 0; }
.wi-query-wrap textarea {
  width: 100%; resize: none; font: inherit; font-size: 14px; line-height: 1.45;
  min-height: 58px; max-height: 30vh; overflow-y: auto; color: var(--text);
}
.wi-find {
  flex-shrink: 0; width: 46px; padding: 0; display: grid; place-items: center;
  border-radius: 13px; white-space: nowrap;
}
.wi-find svg { width: 19px; height: 19px; }
.wi-find .spin { margin: 0; }
.rp-check { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.rp-check svg { width: 12px; height: 12px; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(2, 6, 23, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 28px; cursor: zoom-out; }
.lightbox img { max-width: min(92vw, 1100px); max-height: 82vh; border-radius: 14px; box-shadow: var(--shadow-lg); cursor: default; }
.lightbox-bar { display: flex; align-items: center; gap: 14px; color: #fff; font-size: 13px; cursor: default; }
.lightbox-bar .lb-sub { display: block; font-size: 12px; font-style: normal; opacity: .72; margin-top: 2px; }
.media-add { border: 1.6px dashed rgba(127, 140, 255, .55); background: rgba(127, 140, 255, .08); color: #7f8cff; cursor: pointer; transition: border-color .15s, background .15s; }
.media-add:hover { border-color: #7f8cff; background: rgba(127, 140, 255, .16); }
.media-tiles.drag-files { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 10px; }
.media-tiles.drag-files .media-add { border-color: var(--accent); background: var(--accent-soft); }
.media-add span { text-shadow: none; }
.media-add.is-static { cursor: default; pointer-events: none; }
.seg-sm { margin-bottom: 2px; }
.seg-sm .seg-btn { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .cal-layout { grid-template-columns: 1fr; }
  .pub-layout { grid-template-columns: 1fr; grid-template-rows: none; height: auto; min-height: 0; }
  .pub-sec .pub-list { max-height: 320px; flex: 0 0 auto; }
  .wk-grid { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(130px, 1fr); }
  .wk-day { min-height: 0; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .editor-stages, .editor-side { overflow: visible; }
  .editor-side { position: static; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 1180px) {
  .agents-layout .fr-2 { grid-template-columns: 1fr; }
  .agents-layout .radio-cards { grid-template-columns: 1fr; }
}
@media (max-width: 940px) {
  .agents-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  /* свёрнутый на десктопе чат не должен ломать одноколоночную раскладку */
  .app.chat-hidden { grid-template-columns: 1fr; }
  /* чат уезжает в выдвижную шторку слева (бургер в шапке) */
  .chat-side {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(500px, 92vw); transform: translateX(-105%);
    transition: transform .25s ease; background: var(--surface); box-shadow: var(--shadow-lg);
  }
  .chat-side.open { transform: none; }
  /* в выдвижной шторке карточка чата — на всю ширину, без двойной оболочки */
  .chat-side .chat-wrap { margin: 0; border: 0; border-radius: 0; }
  .burger { display: grid; }
  /* на узких экранах панелью управляет бургер — кнопка в шапке чата и ушка не нужны */
  #chat-toggle, .chat-open-fab { display: none !important; }
  /* вкладки — отдельной прокручиваемой строкой под шапкой */
  .topbar { flex-wrap: wrap; row-gap: 4px; padding: 4px 14px; }
  .top-nav { order: 10; flex-basis: 100%; }
  .content { padding: 20px 18px 50px; }
  .topbar-user .tu-name { display: none; }
}
/* узкое окно: рельса складывается в две строки — сегменты сверху,
   слот модели занимает всю ширину строкой ниже */
@media (max-width: 1024px) {
  .cal-rail { grid-template-columns: 1fr 1fr; }
  .cal-rail-model { grid-column: 1 / -1; max-width: none; flex-direction: row; align-items: center; }
  .cal-rail-model > span { flex: none; }
  .cal-rail-model .select-wrap { flex: 1 1 auto; }
  .fr-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .pf-row, .fr-2 { grid-template-columns: 1fr; }  .radio-cards { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 74px; padding: 5px; }
  .cal-daynum { width: 22px; height: 22px; font-size: 11px; margin-bottom: 4px; }
  .theme-pick { grid-template-columns: 1fr; }
  .auth-card { padding: 30px 22px; }
}

/* Usage tables remain readable beside the chat and on narrow screens. */
.usage-cols > .card { min-width: 0; }
.usage-cols .card-body, .usage-scroll { overflow-x: auto; }
@media (max-width: 1100px) { .usage-cols { grid-template-columns: 1fr; } }

/* Calendar of daily model usage; weeks run horizontally, Monday first. */
.uh-note { margin: 0 0 20px; }
.uh-scroll { overflow-x: auto; padding: 2px 2px 8px; }
.uh-calendar { --uh-size: 18px; --uh-gap: 5px; display: grid; grid-template-columns: 26px max-content; grid-template-rows: 20px auto; gap: 6px 8px; width: max-content; }
.uh-months { grid-column: 2; display: grid; grid-template-columns: repeat(var(--uh-weeks), var(--uh-size)); gap: var(--uh-gap); color: var(--muted); font-size: 11px; }
.uh-months span { white-space: nowrap; }
.uh-weekdays { grid-row: 2; display: grid; grid-template-rows: repeat(7, var(--uh-size)); gap: var(--uh-gap); font-size: 10px; color: var(--faint); align-items: center; }
.uh-grid { grid-row: 2; grid-column: 2; display: grid; grid-template-columns: repeat(var(--uh-weeks), var(--uh-size)); grid-template-rows: repeat(7, var(--uh-size)); gap: var(--uh-gap); }
.uh-cell { display: block; width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 4px; padding: 0; background: var(--surface-3); }
button.uh-cell { cursor: pointer; transition: outline-color .15s, transform .15s; }
.uh-cell[data-level="1"] { background: #b8eacd; }
.uh-cell[data-level="2"] { background: #6fd79c; }
.uh-cell[data-level="3"] { background: #22a05e; }
.uh-cell[data-level="4"] { background: #0b6b3d; }
:root[data-theme="dark"] .uh-cell[data-level="1"] { background: #1d4a39; }
:root[data-theme="dark"] .uh-cell[data-level="2"] { background: #1a7a51; }
:root[data-theme="dark"] .uh-cell[data-level="3"] { background: #23a869; }
:root[data-theme="dark"] .uh-cell[data-level="4"] { background: #56dd9a; }
button.uh-cell:hover, button.uh-cell:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; transform: scale(1.08); }
.uh-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--faint); font-size: 11px; }
.uh-scale { display: flex; align-items: center; gap: 5px; }
.uh-scale .uh-cell { width: 13px; height: 13px; border-radius: 3px; }
.uh-scale span:first-child { margin-right: 3px; }
.uh-scale span:last-child { margin-left: 3px; }
.uh-tooltip { position: fixed; z-index: 1000; max-width: min(340px, calc(100vw - 16px)); padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); font-size: 12px; line-height: 1.7; pointer-events: none; }
.uh-tooltip[hidden] { display: none; }
.uh-tooltip b { display: block; margin-bottom: 4px; }
.uh-tip-muted { color: var(--muted); }

/* Let content shrink inside grid/flex tracks and wrap before card edges. */
.content, .card, .card-head > *, .stat, .agent-detail { min-width: 0; }
.card-head { flex-wrap: wrap; }
.card-head h3 { overflow-wrap: anywhere; }
.card-head h3 svg { flex-shrink: 0; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .st-val, .stat .st-lbl { overflow-wrap: anywhere; }
.models-hint { white-space: normal; flex-wrap: wrap; overflow-wrap: anywhere; }
.agent-item .ai-main b { white-space: normal; overflow-wrap: anywhere; }
.models-detail .mc-foot { flex-wrap: wrap; }
.set-layout { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
[data-view="usage"] { display: grid; gap: 14px; }
[data-view="usage"] > .card, [data-view="usage"] .usage-cols { min-width: 0; }
[data-view="usage"] .card-body { padding: 16px 18px; min-width: 0; }
[data-view="usage"] .card-head .grow { flex: 1 1 0; }
[data-view="usage"] .card-head .seg { flex-shrink: 0; max-width: 100%; }
[data-view="usage"] .stats { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
[data-view="usage"] .usage-note { overflow-wrap: anywhere; }
[data-view="usage"] .card-body:has(> .usage-table) { overflow-x: auto; }
.usage-table { table-layout: fixed; }
.usage-table th, .usage-table td { overflow-wrap: anywhere; }
.usage-table th { font-size: 10.5px; letter-spacing: .02em; }
.usage-table .num { white-space: normal; }
.usage-table .share { width: 100px; }
.usage-table code { white-space: normal; overflow-wrap: anywhere; }
.us-top { flex-wrap: wrap; }
.us-top > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.uh-tooltip { overflow-wrap: anywhere; max-height: calc(100vh - 16px); overflow-y: auto; }
.uh-months { overflow: visible; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  [data-view="usage"] .card-head { gap: 8px; padding: 12px 14px; }
  [data-view="usage"] .card-body { padding: 14px; }
  [data-view="usage"] .card-head h3 { flex: 1 1 55%; }
  [data-view="usage"] #usage-days { width: 100%; justify-content: space-between; }
  [data-view="usage"] .usage-table { min-width: 460px; }
}

.usage-table .share i { max-width: calc(100% - 46px); }
.topbar { min-width: 0; }
@media (max-width: 900px) {
  .app, .app.chat-hidden { grid-template-columns: minmax(0, 1fr); }
}

/* Keep large model traces isolated from the page layout. */
.debug-body { min-height: 0; min-width: 0; overscroll-behavior: contain; }
.debug-body .dbg-sec, .debug-body details, .dbg-msg { min-width: 0; }
.debug-body pre { overflow-wrap: anywhere; contain: content; }
.dbg-more { margin-top: 8px; white-space: normal; }
