:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dfe2e8;
  --text: #1c2029;
  --muted: #687082;
  --accent: #3554d1;
  --accent-text: #ffffff;
  --accent-soft: #e8ecfb;
  --ok: #1d7a4c;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --danger: #c0352b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1d2027;
    --surface-2: #262a33;
    --border: #333844;
    --text: #e8eaf0;
    --muted: #98a0b3;
    --accent: #7f97ff;
    --accent-text: #10131c;
    --accent-soft: #262d4a;
    --ok: #5fcf96;
    --warn-bg: #3a3010;
    --warn-text: #f1d58a;
    --danger: #ff8278;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }

input[type=text], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 42px; }

/* Вход */
.login {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  gap: 14px;
}
.login h1 { font-size: 22px; }
.login p { margin: 0; color: var(--muted); }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

/* Шапка */
header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-row {
  max-width: 980px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.who { color: var(--muted); font-size: 14px; }
.banner { background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
.banner div { max-width: 980px; margin: 0 auto; padding: 8px 16px; }

main { max-width: 980px; margin: 0 auto; padding: 16px; }

.chips, .tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
}
.count.hot { background: var(--accent); color: var(--accent-text); }

.tabs { margin: 16px 0 12px; border-bottom: 1px solid var(--border); gap: 2px; }
.tab {
  border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected=true] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input { max-width: 320px; }
.hint { color: var(--muted); font-size: 13px; }

/* Значки площадок и аватары аккаунтов */
.picon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.picon svg { width: 100%; height: 100%; display: block; }
.avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .picon { position: absolute; right: -4px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); background: var(--surface); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; }
.chip:first-child { padding-left: 14px; }
.chip .count { margin-left: 0; }
.badge.acc { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }
.badge.acc .picon { width: 14px; height: 14px; }

/* Карточка комментария */
.card {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  transition: opacity .25s;
}
.card.gone { opacity: 0; }
.thumb {
  width: 64px; height: 80px; border-radius: 8px; overflow: hidden; display: block;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.meta b { color: var(--text); font-size: 15px; }
.badge { border-radius: 6px; padding: 1px 7px; font-size: 12px; background: var(--surface-2); }
.badge.kw { background: var(--warn-bg); color: var(--warn-text); }
.card .text { margin: 6px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.post { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.reply-shown {
  margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--border);
  background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.reply-shown small { display: block; color: var(--muted); margin-top: 2px; }
.composer { margin-top: 10px; display: grid; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select { width: auto; max-width: 220px; padding: 6px 8px; }
.actions .spacer { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.center { text-align: center; margin: 16px 0; }

/* Настройки */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.panel h2 { font-size: 17px; margin-bottom: 4px; }
.panel > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.form-row label { flex: 1 1 160px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-scroll table th { position: sticky; top: 0; background: var(--surface); }
.table-scroll td, .table-scroll th { padding-left: 10px; padding-right: 10px; }
.words { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow: auto; }
.word { background: var(--surface-2); border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 13px; display: inline-flex; align-items: center; gap: 2px; }
.word button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 15px; }
.word button:hover { color: var(--danger); }
.word.eq { outline: 1px dashed var(--border); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }

@media (max-width: 560px) {
  .card { grid-template-columns: 1fr; }
  .thumb { display: none; }
  .toolbar { flex-wrap: wrap; }
}
