/* =====================================================================
   BoostBox · дизайн v2 — общие токены и компоненты
   Используется и мини-аппом (miniapp.html), и сайтом для ПК (web.html).

   Референс — консоль Polza AI (папка «пример сайта»): почти чёрные
   поверхности, тонкие границы вместо теней, Inter с плотной типографикой,
   лаймовый бренд-цвет, «сторис» со светящимися объектами.

   Цвет несёт смысл (правило проекта сохраняем):
     лайм   — подписки, рост, главное действие (бренд = рост, это и есть продукт)
     янтарь — деньги
     коралл — потери, отписки, ошибки
     фиолет — переходы и прочие нейтральные серии
   ===================================================================== */

:root {
  color-scheme: dark;

  /* Поверхности */
  --bg: #0b0d10;
  --surface: #121519;
  --surface-2: #171a20;
  --surface-3: #1f232b;
  --hover: rgba(255, 255, 255, 0.04);
  --line: #22262f;
  --line-strong: #30343d;

  /* Текст */
  --text: #f5f6f7;
  --text-2: #cecfd2;
  --muted: #94979c;
  --faint: #61656c;

  /* Бренд / рост */
  --brand: #a2ef0c;
  --brand-strong: #88c80c;
  --brand-text: #b8f53f;
  --brand-ink: #0f1a02;
  --brand-soft: rgba(162, 239, 12, 0.12);
  --brand-line: rgba(162, 239, 12, 0.32);
  --brand-glow: 0 0 0 1px rgba(162, 239, 12, 0.35), 0 8px 32px -8px rgba(162, 239, 12, 0.45);

  /* Рост в графиках — в светлой теме темнее, чтобы лайм не терялся на белом */
  --up: #a2ef0c;

  /* Смысловые */
  --money: #fdb022;
  --money-soft: rgba(253, 176, 34, 0.12);
  --loss: #f97066;
  --loss-soft: rgba(249, 112, 102, 0.12);
  --info: #9e77ed;
  --info-soft: rgba(158, 119, 237, 0.14);
  --sky: #53b1fd;

  /* Графики */
  --grid: rgba(255, 255, 255, 0.06);

  /* Форма */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  --shadow-pop: 0 24px 64px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
  --glass: rgba(18, 21, 25, 0.72);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f0f1f3;
  --hover: rgba(10, 13, 18, 0.04);
  --line: #e9eaeb;
  --line-strong: #d5d7da;

  --text: #0f1216;
  --text-2: #414651;
  --muted: #717680;
  --faint: #a4a7ae;

  --brand: #a2ef0c;
  --brand-strong: #88c80c;
  --brand-text: #4f7a0a;
  --brand-ink: #0f1a02;
  --brand-soft: rgba(136, 200, 12, 0.14);
  --brand-line: rgba(111, 163, 12, 0.4);
  --brand-glow: 0 0 0 1px rgba(111, 163, 12, 0.45), 0 8px 24px -10px rgba(111, 163, 12, 0.5);

  --up: #7cb70a;
  --money: #dc6803;
  --money-soft: rgba(247, 144, 9, 0.12);
  --loss: #d92d20;
  --loss-soft: rgba(240, 68, 56, 0.1);
  --info: #7a5af8;
  --info-soft: rgba(122, 90, 248, 0.1);
  --sky: #1570ef;

  --grid: rgba(10, 13, 18, 0.07);
  --shadow-pop: 0 24px 48px -12px rgba(10, 13, 18, 0.18), 0 0 0 1px var(--line);
  --glass: rgba(255, 255, 255, 0.78);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; }

/* ---------- Типографика ---------- */
.h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; margin: 0; }
.h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }
.h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.num { font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.c-brand { color: var(--brand-text); }
.c-money { color: var(--money); }
.c-loss { color: var(--loss); }
.c-info { color: var(--info); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .2s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--brand); color: var(--brand-ink); border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.2);
}
.btn-primary:hover { background: #b2f72a; box-shadow: var(--brand-glow); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; border-radius: var(--r-md); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.dot-badge {
  position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--loss); box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ---------- Бейджи, чипы ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line);
}
.badge-brand { background: var(--brand-soft); color: var(--brand-text); border-color: var(--brand-line); }
.badge-money { background: var(--money-soft); color: var(--money); border-color: transparent; }
.badge-loss { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-new {
  background: linear-gradient(90deg, var(--brand), #d4ff6b); color: var(--brand-ink);
  border: 0; font-size: 10.5px; height: 18px; padding: 0 6px; letter-spacing: .02em; text-transform: uppercase;
}
.delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--brand-text); }
.delta.down { color: var(--loss); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Сегментированный переключатель ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.seg button {
  height: 28px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 550;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 0 0 1px var(--line-strong); }

/* ---------- Поля ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand-strong); box-shadow: 0 0 0 4px var(--brand-soft); }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }

.toggle { position: relative; width: 36px; height: 20px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .2s; }
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + span { background: var(--brand-strong); }
.toggle input:checked + span::after { transform: translateX(16px); }

/* ---------- Прогресс ---------- */
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

/* ---------- Таблица ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 550; color: var(--muted);
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--hover); cursor: pointer; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Аватар канала ---------- */
.ava {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 13px; color: #0b0d10;
}

/* ---------- Логотип ---------- */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -0.03em; font-size: 17px; color: var(--text); }
.logo .wordmark { display: block; overflow: visible; }
.logo-icon { border-radius: 22%; flex: none; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 20% 0%, #e2ff9e 0%, var(--brand) 45%, #5f8f05 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 6px 20px -6px rgba(162,239,12,.6);
}
.logo-mark svg { width: 18px; height: 18px; }

/* ---------- Сторис ---------- */
.stories { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.stories::-webkit-scrollbar { display: none; }
.story {
  position: relative; flex: none; width: 112px; height: 150px; border-radius: 16px; overflow: hidden;
  border: 0; padding: 0; background: #050607; text-align: left; isolation: isolate;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform .25s var(--ease), box-shadow .25s;
}
.story:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-strong), 0 12px 30px -12px var(--glow, #a2ef0c); }
.story.unseen::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 2px; z-index: 3;
  background: linear-gradient(140deg, var(--glow), transparent 55%, var(--glow));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.story .orb { position: absolute; inset: 0; z-index: 0; }
.story .t {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  color: #fff; font-size: 12.5px; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em;
  text-shadow: 0 1px 8px rgba(0,0,0,.6);
}
.story::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.75));
}

/* Светящийся «объект» внутри сторис — CSS-аналог глянцевых 3D-логотипов референса */
.glowobj {
  position: absolute; left: 50%; top: 40%; width: 64%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 30%;
  background:
    radial-gradient(60% 60% at 35% 30%, rgba(255,255,255,.85), transparent 60%),
    conic-gradient(from 210deg, var(--glow), #fff 18%, var(--glow) 35%, rgba(0,0,0,.6) 55%, var(--glow) 80%, #fff 92%, var(--glow));
  filter: saturate(1.2);
  box-shadow: 0 0 40px 4px color-mix(in srgb, var(--glow) 55%, transparent), inset 0 0 18px rgba(255,255,255,.5);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 26%, #000 27%);
          mask: radial-gradient(circle at 50% 50%, transparent 26%, #000 27%);
  animation: spin 18s linear infinite;
}
.glowobj.sq { border-radius: 24%; transform: translate(-50%, -50%) rotate(45deg); animation: none; }
.glowobj.tri { border-radius: 0; clip-path: polygon(50% 4%, 96% 86%, 4% 86%); -webkit-mask: none; mask: none; animation: none;
  background: radial-gradient(60% 60% at 40% 35%, rgba(255,255,255,.9), transparent 60%), linear-gradient(160deg, #fff, var(--glow) 40%, rgba(0,0,0,.7)); }
.story .floor {
  position: absolute; left: 10%; right: 10%; top: 66%; height: 20px; z-index: 0;
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--glow) 55%, transparent), transparent 70%);
  filter: blur(6px);
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Просмотрщик сторис */
.story-viewer {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center;
  background: rgba(0,0,0,.82); backdrop-filter: blur(10px);
}
.story-viewer.open { display: grid; animation: fade .2s ease; }
.sv-frame {
  position: relative; width: min(400px, 100vw); height: min(711px, 100dvh); border-radius: 22px; overflow: hidden;
  background: #050607; color: #fff;
}
.sv-bars { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 5; }
.sv-bars i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.sv-bars i b { display: block; height: 100%; width: 0; background: #fff; }
.sv-bars i.done b { width: 100%; }
.sv-bars i.run b { animation: bar 6s linear forwards; }
@keyframes bar { to { width: 100%; } }
.sv-close { position: absolute; top: 24px; right: 14px; z-index: 6; background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; }
.sv-body { position: absolute; left: 24px; right: 24px; bottom: 28px; z-index: 4; }
.sv-body .k { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; font-weight: 600; }
.sv-body h3 { font-size: 26px; line-height: 1.12; letter-spacing: -0.03em; margin: 8px 0 10px; }
.sv-body p { margin: 0 0 18px; opacity: .82; font-size: 15px; }
.sv-frame .glowobj { width: 58%; top: 34%; }
.sv-frame .floor { position: absolute; left: 15%; right: 15%; top: 56%; height: 40px; filter: blur(14px);
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--glow) 50%, transparent), transparent 70%); }
.sv-nav { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 2fr; z-index: 3; }
.sv-nav button { background: none; border: 0; }

/* ---------- Подсказка-тултип для графиков ---------- */
.tip {
  position: absolute; pointer-events: none; z-index: 20; min-width: 150px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow-pop); opacity: 0; transition: opacity .12s;
}
.tip.show { opacity: 1; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 300;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  opacity: 0; transition: opacity .2s, transform .25s var(--ease); pointer-events: none;
  display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.rise { animation: rise .45s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Движение. Правила: 150–350 мс на интерфейс, до 900 мс на «рост» данных;
   одна кривая var(--ease); анимируем только transform/opacity/dashoffset;
   повторный рендер от ввода/степпера идёт с .calm — без повторных анимаций.
   ===================================================================== */
@keyframes growY { from { transform: scaleY(0); } }
@keyframes growX { from { transform: scaleX(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }
@keyframes ringIn { from { stroke-dashoffset: var(--c); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes svIn { from { opacity: 0; transform: scale(.92) translateY(12px); } }
@keyframes bellRing { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
@keyframes slideL { from { opacity: 0; transform: translateX(28px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-28px); } }

/* Графики */
.anim .bar-up { transform-box: fill-box; transform-origin: 50% 100%; animation: growY .6s var(--ease) both; }
.anim .bar-dn { transform-box: fill-box; transform-origin: 50% 0%; animation: growY .6s var(--ease) both; }
.anim .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s cubic-bezier(.4, 0, .2, 1) .15s forwards; }
.anim .fade { animation: fadeIn .9s ease .3s both; }
.anim .hc { transform-box: fill-box; transform-origin: center; animation: pop .45s var(--ease) both; }
.ring-arc { animation: ringIn 1.2s var(--ease) .1s both; }

/* Полосы прогресса и воронки растут слева */
.progress > i, .fstep .bar i, .f-row .bar i, .split i { transform-origin: left center; animation: growX .8s var(--ease) both; }

/* Каскад появления страницы */
.page-in > *, .page-in .grid > *, .page-in .kgrid > *, .page-in .podium > * { animation: rise .5s var(--ease) both; }
.page-in > *:nth-child(2), .page-in .grid > *:nth-child(2), .page-in .kgrid > *:nth-child(2) { animation-delay: .04s; }
.page-in > *:nth-child(3), .page-in .grid > *:nth-child(3), .page-in .kgrid > *:nth-child(3) { animation-delay: .08s; }
.page-in > *:nth-child(4), .page-in .grid > *:nth-child(4), .page-in .kgrid > *:nth-child(4) { animation-delay: .12s; }
.page-in > *:nth-child(5) { animation-delay: .16s; }
.page-in > *:nth-child(6) { animation-delay: .2s; }
.page-in > *:nth-child(n+7) { animation-delay: .24s; }
.page-in .table tbody tr { animation: rise .4s var(--ease) both; }
.page-in .table tbody tr:nth-child(2) { animation-delay: .03s; }
.page-in .table tbody tr:nth-child(3) { animation-delay: .06s; }
.page-in .table tbody tr:nth-child(4) { animation-delay: .09s; }
.page-in .table tbody tr:nth-child(n+5) { animation-delay: .12s; }

/* Смена фильтра: перестраивается только список */
.rows-in .table tbody tr, .rows-in .litem { animation: rise .35s var(--ease) both; }
.rows-in .table tbody tr:nth-child(2) { animation-delay: .03s; }
.rows-in .table tbody tr:nth-child(3) { animation-delay: .06s; }
.rows-in .table tbody tr:nth-child(n+4) { animation-delay: .09s; }

/* Повторный рендер без анимаций (ввод в поле, степпер, смена темы) */
.calm, .calm *, .calm *::before, .calm *::after { animation: none !important; }

/* Загрузка: шиммер поверх карточек, цифры притухают */
.is-loading .card, .is-loading .kmini, .is-loading .litem { position: relative; overflow: hidden; }
.is-loading .card::after, .is-loading .kmini::after, .is-loading .litem::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  animation: shimmer 1s ease-in-out infinite;
}
.is-loading .num, .is-loading .card svg.anim, .is-loading .card [id] svg, .is-loading .v, .is-loading .val { opacity: .2; filter: blur(3px); transition: opacity .2s, filter .2s; }
.num, .v, .val { transition: opacity .25s, filter .25s; }

/* Сторис и колокольчик */
.story-viewer.open .sv-frame { animation: svIn .35s var(--ease); }
.story-viewer.open .sv-body > * { animation: rise .5s var(--ease) both; }
.story-viewer.open .sv-body > *:nth-child(2) { animation-delay: .06s; }
.story-viewer.open .sv-body > *:nth-child(3) { animation-delay: .12s; }
.story-viewer.open .sv-body > *:nth-child(4) { animation-delay: .18s; }
.bell-ring svg { transform-origin: 50% 10%; animation: bellRing .9s ease 1.2s; }

/* Отклик на нажатие */
.btn, .chip, .icon-btn, .story, .litem, .mrow, .tab, .src-opt, .chsel { -webkit-tap-highlight-color: transparent; }
.chip, .seg button, .tab { transition: background .2s, color .2s, border-color .2s, transform .12s; }
.chip:active, .icon-btn:active, .tab:active { transform: scale(.94); }

/* ---------- Полировка: закрытия, ползунки, фокус, тема ---------- */
@keyframes fadeOut { to { opacity: 0; } }
@keyframes dropOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes spinner { to { transform: rotate(360deg); } }

/* Ползунок сегмент-контрола переезжает, а не перескакивает */
.seg { position: relative; }
.seg .thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 6px; z-index: 0; pointer-events: none;
  background: var(--surface-3); box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 0 0 1px var(--line-strong);
  transition: transform .32s var(--ease), width .32s var(--ease);
}
.seg .thumb.no-tr { transition: none; }
.seg button { position: relative; z-index: 1; }
.seg.has-thumb button.active { background: none; box-shadow: none; }

/* Подсказка графика и подсветка столбца едут плавно */
.tip { transition: opacity .12s, left .12s ease-out, top .12s ease-out; }
.hl { transition: x .14s ease-out, opacity .15s; }
.hc { transition: stroke-width .12s; stroke: var(--text); stroke-width: 0; }
.hc:hover { stroke-width: 1.5; }

/* Фокус с клавиатуры */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.input:focus-visible { outline: none; }

/* Кнопка: «Скопировано» и загрузка */
.btn.copied { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-text); }
.btn.copied svg { animation: pop .3s var(--ease); }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spinner .7s linear infinite; }
.btn.loading { pointer-events: none; opacity: .85; }

/* Закрытие слоёв — тоже анимировано */
.modal-wrap.closing { animation: fadeOut .16s ease forwards; }
.modal-wrap.closing .modal { animation: dropOut .16s ease forwards; }
.story-viewer.closing { animation: fadeOut .2s ease forwards; }
.story-viewer.closing .sv-frame { animation: dropOut .2s ease forwards; }

/* Смена темы: круг из кнопки (View Transitions), иначе — плавная перекраска */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-fade, .theme-fade * { transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease !important; }

/* Прочитанные уведомления гасят точку */
.notif::after { transition: opacity .3s, transform .3s var(--ease); }
.notif.read::after { opacity: 0; transform: scale(0); }


/* ---------- Яндекс: Метрика и Директ в мастере ссылки ---------- */
@keyframes reveal { from { opacity: 0; transform: translateY(-6px); } }
.reveal { animation: reveal .35s var(--ease) both; }
.ysec { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); overflow: hidden; transition: border-color .25s, box-shadow .25s; }
.ysec.on { border-color: var(--brand-line); box-shadow: 0 0 0 4px var(--brand-soft); }
.ysec-h { display: flex; align-items: flex-start; gap: 12px; padding: 14px; cursor: pointer; }
.ysec-h .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); transition: background .25s, color .25s; }
.ysec.on .ysec-h .ic { background: var(--brand); color: var(--brand-ink); }
.ysec-h .ic svg { width: 18px; height: 18px; }
.ysec-h .tx { flex: 1; min-width: 0; }
.ysec-h .tx b { display: flex; align-items: center; gap: 6px; font-size: 14.5px; }
.ysec-h .tx span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ysec-b { padding: 0 14px 14px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.ystat { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ystat.ok { background: var(--brand); color: var(--brand-ink); }
.ystat.ok svg { width: 12px; height: 12px; }
.ystat.wait { border: 2px solid var(--money); }

.yid-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 46px; border-radius: 12px; border: 0;
  background: #000; color: #fff; font-weight: 600; font-size: 15px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
:root[data-theme="light"] .yid-btn { background: #000; }
.yid-btn:hover { background: #1a1a1a; }
.yid-btn.waiting { pointer-events: none; }

.acc-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 550; transition: border-color .2s, background .2s; }
.acc-chip .a { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #FC3F1D; color: #fff; font-size: 12px; font-weight: 800; }
.acc-chip.on { border-color: var(--brand-line); background: var(--brand-soft); }
.acc-chip.add { color: var(--muted); padding: 0 12px; }

.counter-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.counter-card .m { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, #ffcc00, #ff9500); color: #1a1200; }
.counter-card .m svg { width: 18px; height: 18px; }
.counter-card .x { flex: 1; min-width: 0; }
.counter-card .x .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.counter-card .x b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter-card .x .mono { color: var(--muted); font-size: 12.5px; }

.goals { display: grid; gap: 6px; }
.goal-i { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.goal-i .ystat { animation: pop .35s var(--ease) both; }
.goal-i.pending .ystat { background: none; border: 2px solid var(--line-strong); animation: none; }
.goal-i.pending { color: var(--faint); }

.camp-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-height: 232px; overflow-y: auto; }
.camp { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; width: 100%; transition: border-color .2s, background .2s; }
.camp:hover { border-color: var(--line-strong); }
.camp.on { border-color: var(--brand-line); background: var(--brand-soft); }
.camp .rd { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; position: relative; transition: border-color .2s; }
.camp.on .rd { border-color: var(--brand-strong); }
.camp.on .rd::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--brand-strong); animation: pop .25s var(--ease); }
.camp .x { flex: 1; min-width: 0; }
.camp .x b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp .x span { font-size: 12px; color: var(--muted); }
.camp .c { font-weight: 700; color: var(--money); font-size: 13.5px; white-space: nowrap; }

.budget-auto { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px dashed var(--brand-line); background: var(--brand-soft); font-size: 13.5px; }
.budget-auto svg { width: 16px; height: 16px; color: var(--brand-text); flex: none; }
.budget-auto b { color: var(--money); }

.howto { display: grid; gap: 10px; counter-reset: st; }
.howto li { list-style: none; display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 13px; color: var(--text-2); }
.howto li::before { counter-increment: st; content: counter(st); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-weight: 700; font-size: 12.5px; }
.howto code { font-family: var(--mono); font-size: 12px; padding: 1px 5px; border-radius: 5px; background: var(--surface-3); color: var(--text); }
.pro-tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; background: linear-gradient(90deg, #fdb022, #ffd166); color: #2a1a00; }
.more-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; color: var(--muted); font-size: 13px; font-weight: 550; }
.more-link:hover { color: var(--text); }
.more-link svg { width: 14px; height: 14px; transition: transform .25s var(--ease); }
.more-link.open svg { transform: rotate(180deg); }
.success-mark { width: 64px; height: 64px; border-radius: 20px; margin: 4px auto 12px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); box-shadow: var(--brand-glow); animation: pop .45s var(--ease) both; }
.success-mark svg { width: 32px; height: 32px; }
.success-mark svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s ease .25s forwards; }

.btn:disabled { opacity: .45; pointer-events: none; box-shadow: none; }
