/* Комменто · единый кабинет владельца.
   Та же дизайн-система, что у мини-аппа (style.css): блок токенов продублирован. */

/* ---------- Токены ---------- */
:root {
  color-scheme: light dark;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #edeff5;
  --fg: #16181d;
  --muted: #6e7686;
  --line: #e3e6ee;

  --accent: #4e6af0;
  --accent-strong: #4157d8;
  --accent-soft: rgba(78, 106, 240, .11);
  --accent-fg: #ffffff;
  --grad: linear-gradient(135deg, #4e6af0, #8b5cf6);

  --danger: #d33c4e;
  --danger-soft: rgba(211, 60, 78, .10);
  --ok: #1f8a54;
  --ok-soft: rgba(31, 138, 84, .12);
  --amber: #9a6700;
  --amber-soft: rgba(224, 158, 22, .14);
  --amber-line: rgba(190, 138, 26, .55);

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;

  --shadow-1: 0 1px 2px rgba(18, 22, 33, .05), 0 2px 10px rgba(18, 22, 33, .05);
  --shadow-2: 0 4px 12px rgba(18, 22, 33, .08), 0 12px 32px rgba(18, 22, 33, .14);
  --blur-bg: rgba(245, 246, 250, .84);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101218;
    --surface: #181b23;
    --surface-2: #222631;
    --fg: #e9ebf1;
    --muted: #99a1b0;
    --line: #262b35;

    --accent: #7d8df8;
    --accent-strong: #94a1fa;
    --accent-soft: rgba(125, 141, 248, .16);

    --danger: #f0717c;
    --danger-soft: rgba(240, 113, 124, .14);
    --ok: #58c98b;
    --ok-soft: rgba(88, 201, 139, .14);
    --amber: #e8b458;
    --amber-soft: rgba(232, 180, 88, .13);
    --amber-line: rgba(232, 180, 88, .45);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .28), 0 2px 10px rgba(0, 0, 0, .22);
    --shadow-2: 0 6px 16px rgba(0, 0, 0, .32), 0 16px 40px rgba(0, 0, 0, .42);
    --blur-bg: rgba(16, 18, 24, .8);
  }
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* ---------- Шапка ---------- */
.head {
  position: sticky;
  top: 0;
  background: var(--blur-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  z-index: 5;
}
.head h1 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.me { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Вкладки с анимированным подчёркиванием ---------- */
.tabs {
  position: sticky;
  top: 49px;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  background: var(--blur-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--line);
  z-index: 4;
}
/* на экране канала вкладки прячутся атрибутом hidden: display:flex его перебивает */
.tabs[hidden] { display: none; }
.tab {
  position: relative;
  flex: 1 1 0;
  max-width: 236px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  min-height: 46px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color .18s var(--ease);
}
.tab::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--grad);
  transform: scaleX(0);
  transition: transform .22s var(--ease);
}
.tab.active { color: var(--fg); }
.tab.active::after { transform: scaleX(1); }
.tab:hover { color: var(--fg); }
.tab.locked { opacity: .5; }
.tab-badge {
  background: var(--grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  min-width: 18px;
  text-align: center;
  border-radius: 999px;
  padding: 0 5px;
}

.content { padding: 16px; max-width: 720px; margin: 0 auto; }

/* ---------- Скелетон и пустые состояния ---------- */
.loader { color: var(--muted); text-align: center; padding: 4px 0 28px; font-size: 14px; }
.sk {
  display: block;
  background: var(--surface-2);
  border-radius: var(--r-l);
  position: relative;
  overflow: hidden;
}
.sk::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: shimmer 1.4s infinite;
}
@media (prefers-color-scheme: dark) {
  .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent); }
}
.sk-card { height: 108px; margin-bottom: 12px; }
.sk-card.short { height: 64px; }
@keyframes shimmer { to { transform: translateX(100%); } }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 48px 24px;
  color: var(--fg);
}
.empty[hidden] { display: none; }
.empty-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.empty-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.empty-hint { color: var(--muted); font-size: 14px; max-width: 420px; }

/* ---------- Апсейл на free/pro ---------- */
.upsell {
  background: linear-gradient(135deg, var(--accent-soft), rgba(139, 92, 246, .10));
  border: 1px solid var(--accent-soft);
  border-radius: var(--r-l);
  padding: 16px;
  margin-bottom: 14px;
}
.upsell strong { font-size: 15px; letter-spacing: -.01em; }
.upsell p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Карточки каналов (обзор) ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } }
.channel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer; /* тап по карточке открывает экран канала */
  animation: rise .28s var(--ease) both;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.channel-card:active { transform: scale(.985); }
@media (hover: hover) {
  .channel-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
}
.channel-card .top { display: flex; align-items: center; gap: 10px; }
.ch-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  user-select: none;
}
.channel-card .title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.channel-card .stats { display: flex; gap: 24px; }
.channel-card .stat { display: flex; flex-direction: column; }
.channel-card .stats b {
  color: var(--fg);
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.channel-card .stats small { color: var(--muted); font-size: 12px; }
.channel-card .stats .warn b { color: var(--amber); }
.channel-card .role { color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 10px; }

/* Кнопка оплаты/продления тарифа на карточке канала */
.pay-link {
  display: inline-block;
  margin-top: 10px;
  background: var(--grad);
  color: var(--accent-fg);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 650;
  border-radius: var(--r-s);
  padding: 9px 16px;
  box-shadow: 0 3px 10px rgba(94, 100, 243, .3);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.pay-link:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(94, 100, 243, .38); }
.pay-link:active { transform: scale(.96); }

.plan-badge {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  line-height: 14px;
  flex-shrink: 0;
}
.plan-free { background: var(--surface-2); color: var(--muted); }
/* активный пробный период: спокойный синий, без градиентов */
.plan-trial { background: rgba(64, 128, 234, .14); color: #5b93f0; border: 1px solid rgba(64, 128, 234, .3); text-transform: none; letter-spacing: .02em; }
.plan-pro { background: var(--grad); color: #fff; }
.plan-business { background: #241d3f; color: #e9c878; border: 1px solid rgba(233, 200, 120, .35); }

/* ---------- Экран канала: шапка и лента комментариев ---------- */
.ch-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.back-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  border-radius: 999px;
  min-height: 38px;
  padding: 7px 14px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-1);
  transition: transform .14s var(--ease), border-color .16s var(--ease);
}
.back-btn:hover { border-color: var(--accent); }
.back-btn:active { transform: scale(.95); }
.ch-head-title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.ch-stats { color: var(--muted); font-size: 13px; margin-bottom: 14px; font-variant-numeric: tabular-nums; }

/* лента в стиле мини-аппа: аватарки-инициалы + пузыри */
.ch-comments { display: flex; flex-direction: column; }
.ch-comment {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  animation: rise .28s var(--ease) both;
}
.ch-comment .ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}
.ch-comment .c-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ch-comment .meta { display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.ch-comment .author {
  font-weight: 650;
  font-size: 13.5px;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-comment .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; margin-left: auto; }
.ch-comment .bubble {
  align-self: flex-start;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  border-top-left-radius: 6px;
  box-shadow: var(--shadow-1);
  padding: 9px 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
/* комментарий на премодерации: пунктир + янтарный бейдж, как в мини-аппе */
.ch-comment.pending .bubble {
  background: var(--amber-soft);
  border: 1px dashed var(--amber-line);
  box-shadow: none;
}
.ch-comment .badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 999px;
  padding: 1px 8px;
  flex-shrink: 0;
}
.ch-comment .post-ref {
  color: var(--muted);
  font-size: 12px;
  padding-left: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-comment .actions { display: flex; gap: 6px; padding-left: 2px; flex-wrap: wrap; }
.ch-comment .actions button {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -2px 0;
  transition: color .16s var(--ease), transform .14s var(--ease);
}
.ch-comment .actions button:hover { color: var(--fg); }
.ch-comment .actions button:active { transform: scale(.94); }
.ch-comment .actions .approve { color: var(--ok); }
.ch-comment .actions .danger:hover { color: var(--danger); }
.ch-comment .actions button:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- Фильтры (селекты) ---------- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-row label { color: var(--muted); font-size: 13px; font-weight: 600; }
.filter-row select,
select {
  flex: 1;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 10px 36px 10px 12px;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%236e7686' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  box-shadow: var(--shadow-1);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Очередь модерации ---------- */
.queue { display: flex; flex-direction: column; gap: 12px; }
.q-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise .28s var(--ease) both;
}
.q-item .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-item .channel {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  line-height: 16px;
}
.q-item .author { font-weight: 650; font-size: 13.5px; letter-spacing: -.01em; }
.q-item .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; }
.q-item .text {
  background: var(--surface-2);
  border-radius: var(--r-m);
  padding: 9px 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.q-item .actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.q-item .actions button {
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--fg);
  border-radius: var(--r-s);
  min-height: 40px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform .14s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
.q-item .actions button:hover { border-color: var(--line); }
.q-item .actions button:active { transform: scale(.95); }
.q-item .actions .approve { background: var(--ok-soft); color: var(--ok); }
.q-item .actions .approve:hover { border-color: var(--ok); }
.q-item .actions .danger { background: none; border-color: var(--line); color: var(--danger); }
.q-item .actions .danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.q-item .actions button:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- Настройки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  margin-bottom: 14px;
  animation: rise .28s var(--ease) both;
}
.card h2 {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.note {
  background: var(--amber-soft);
  border: 1px dashed var(--amber-line);
  border-radius: var(--r-m);
  color: var(--amber);
  font-size: 13px;
  padding: 11px 13px;
  margin-bottom: 14px;
}
textarea#stopwords {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface-2);
  color: var(--fg);
  padding: 10px 13px;
  font: inherit;
  margin-bottom: 10px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
textarea#stopwords:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  border: none;
  background: var(--grad);
  color: var(--accent-fg);
  border-radius: var(--r-s);
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(94, 100, 243, .3);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(94, 100, 243, .38); }
.btn:active { transform: scale(.96); box-shadow: 0 2px 6px rgba(94, 100, 243, .28); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

/* Тумблеры: настоящий switch со скольжением */
.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 6px 0;
  cursor: pointer;
}
.switch-row > span:first-child { display: flex; flex-direction: column; font-weight: 550; }
.switch-row small { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(18, 22, 33, .3);
  transition: transform .2s var(--ease);
}
.switch-row input:checked ~ .switch { background: var(--grad); border-color: transparent; }
.switch-row input:checked ~ .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible ~ .switch { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Модераторы */
.mods { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--r-s);
  min-height: 44px;
  padding: 8px 13px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.mod-row .owner-mark {
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 4px;
}
.mod-row button {
  background: none;
  border: none;
  color: var(--danger);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 10px;
  margin: -6px -8px;
  transition: background .16s var(--ease);
}
.mod-row button:hover { background: var(--danger-soft); }
.mod-add { display: flex; gap: 8px; }
.mod-add input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface-2);
  color: var(--fg);
  min-height: 44px;
  padding: 8px 13px;
  font: inherit;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.mod-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Тосты ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #23262e;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-m);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 20;
  max-width: calc(100vw - 32px);
  animation: toast-in .24s var(--ease) both;
}
@media (prefers-color-scheme: dark) {
  .toast { background: #2c313c; }
}
.toast.ok::before { content: "✓"; color: #6de3a6; font-weight: 800; margin-right: 8px; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
