/* Комменто · мини-апп ветки комментариев.
   Дизайн-система на CSS-переменных; тот же блок токенов продублирован в cabinet.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; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; -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(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}
.head h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
}
.count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  min-width: 20px;
  text-align: center;
  border-radius: 999px;
  padding: 0 7px;
}
.count:empty { display: none; }
.cabinet-link {
  margin-left: auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 6px 12px;
  transition: transform .16s var(--ease), background .16s var(--ease);
}
.cabinet-link:hover { background: var(--accent); color: var(--accent-fg); }
.cabinet-link:active { transform: scale(.95); }

/* ---------- Лента ---------- */
.list { flex: 1; padding: 14px 16px 118px; max-width: 640px; width: 100%; margin: 0 auto; }

/* Скелетон загрузки */
.loader { color: var(--muted); text-align: center; padding: 6px 0 28px; font-size: 14px; }
.sk-row { display: flex; gap: 10px; padding: 9px 0; text-align: left; }
.sk-col { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.sk {
  display: block;
  background: var(--surface-2);
  border-radius: 8px;
  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-ava { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.sk-line { height: 12px; }
.sk-bubble { height: 38px; border-radius: var(--r-m); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Пустое состояние */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 56px 20px;
}
.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; }

/* ---------- Комментарий ---------- */
.comment {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  animation: rise .28s var(--ease) both;
}
.comment.reply { padding-left: 46px; }
.comment.reply .ava { width: 28px; height: 28px; font-size: 11px; }

.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;
  letter-spacing: .02em;
  user-select: none;
}
.c-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.comment .meta { display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.comment .author {
  font-weight: 650;
  font-size: 13.5px;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comment .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.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 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment .actions { display: flex; gap: 6px; padding-left: 2px; }
.comment .actions button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  padding: 9px 7px;
  margin: -6px -2px -4px;
  transition: color .16s var(--ease), transform .12s var(--ease);
}
.comment .actions button:hover { color: var(--fg); }
.comment .actions button:active { transform: scale(.94); }
.comment .actions .danger:hover { color: var(--danger); }

/* Комментарий на премодерации: пунктир + янтарный бейдж */
.comment.pending .bubble {
  background: var(--amber-soft);
  border: 1px dashed var(--amber-line);
  box-shadow: none;
}
.comment .badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 999px;
  padding: 1px 8px;
  line-height: 16px;
  white-space: nowrap;
}

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

/* ---------- Композер ---------- */
.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--blur-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 6;
}
.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 640px;
  margin: 0 auto;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--fg);
  padding: 11px 16px;
  font: inherit;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer button[type="submit"] {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  background: var(--grad);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(94, 100, 243, .35);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.composer button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(94, 100, 243, .42); }
.composer button[type="submit"]:active { transform: scale(.9); box-shadow: 0 2px 8px rgba(94, 100, 243, .3); }
.composer button[disabled] { opacity: .55; cursor: default; transform: none; }

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  max-width: 640px;
  margin: 0 auto 8px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 6px 6px 10px;
}
/* атрибут hidden должен побеждать display:flex у панели ответа */
.reply-bar[hidden] { display: none; }
.reply-bar button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  transition: color .16s var(--ease);
}
.reply-bar button:hover { color: var(--fg); }

/* ---------- Прочее ---------- */
.banned {
  text-align: center;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-m);
  margin: 0 16px 20px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
}

/* White-label подпись: показывается только на тарифе free */
.brand { text-align: center; padding: 10px 16px 96px; }
.brand a {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: color .16s var(--ease);
}
.brand a:hover { color: var(--fg); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + 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; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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