/* Спокойный минимализм: нейтральные поверхности, тонкие линии, один акцентный цвет.
   Интерфейс рассчитан на многочасовую работу — цвет используется только там, где он что-то сообщает. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e4e4df;
  --border-strong: #cfcfc8;
  --text: #1f2328;
  --muted: #666b73;
  --accent: #3554d1;
  --accent-hover: #2a45b3;
  --accent-text: #ffffff;
  --accent-soft: #e8ecfb;
  --ok: #1d7a4c;
  --warn-bg: #fbf3dc;
  --warn-text: #6f5200;
  --danger: #b4372e;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151719;
    --surface: #1c1f22;
    --surface-2: #25292d;
    --border: #2d3237;
    --border-strong: #3d444b;
    --text: #e6e8ea;
    --muted: #9aa1a9;
    --accent: #7f97ff;
    --accent-hover: #98abff;
    --accent-text: #10131c;
    --accent-soft: #262d4a;
    --ok: #5fcf96;
    --warn-bg: #352c12;
    --warn-text: #ecd28a;
    --danger: #f08a80;
  }
}

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

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  font-size: 14px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.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: 3px 10px; font-size: 13px; }

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

/* Поверхности */
.card, .panel, .login, .dlg-row, .dlg-thread {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Вход */
.login { max-width: 360px; margin: 14vh auto 0; padding: 28px; display: grid; gap: 14px; }
.login h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.login p { margin: 0; color: var(--muted); }
.login .btn { padding: 9px 14px; }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

/* Каркас: боковая панель и содержимое */
.app { display: grid; grid-template-columns: 72px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0;
  background: var(--surface); border-right: 1px solid var(--border);
}
.logo { width: 36px; height: 36px; border-radius: 9px; overflow: hidden; margin-bottom: 14px; display: block; }
.logo img { width: 100%; height: 100%; display: block; }
.side-btn {
  position: relative; width: 56px; padding: 8px 0 6px; border: 0; background: none; border-radius: 8px; cursor: pointer;
  display: grid; justify-items: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 500;
}
.side-btn svg { width: 20px; height: 20px; display: block; }
.side-btn:hover { background: var(--surface-2); color: var(--text); }
.side-btn[aria-current=page] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.side-btn[aria-current=page] svg { color: var(--accent); }
.side-btn.lang b { font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 3px 0; }
.login .btn.lang { justify-self: center; margin-top: 4px; }
.side-btn .pip {
  position: absolute; top: 2px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}
.side-spacer { flex: 1; }
.side-me {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); margin-top: 6px;
}
.content { min-width: 0; }
.page-head { max-width: 960px; margin: 0 auto; padding: 22px 24px 4px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.015em; }
.page-head .who { color: var(--muted); font-size: 13px; margin-left: auto; }
.banner { max-width: 960px; margin: 12px auto 0; padding: 0 24px; }
.banner div { background: var(--warn-bg); color: var(--warn-text); font-size: 14px; border-radius: 8px; padding: 9px 12px; }
main { max-width: 960px; margin: 0 auto; padding: 14px 24px 40px; }

.chips, .tabs { display: flex; flex-wrap: wrap; }
.chips { gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 3px 12px 3px 4px; font-size: 14px; color: var(--muted);
}
.chip:first-child { padding-left: 13px; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed=true] { border-color: var(--text); color: var(--text); font-weight: 600; }
.count {
  display: inline-block; min-width: 20px; padding: 0 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; line-height: 19px;
}
.count.hot { background: var(--accent-soft); color: var(--accent); }

/* Вкладки — подчёркнутые, без плашек */
.tabs { margin: 14px 0 14px; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: none;
  padding: 8px 11px 9px; cursor: pointer; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.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: 300px; }
.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: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 11px; 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: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); background: var(--surface); }
.badge.acc { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }
.badge.acc .picon { width: 13px; height: 13px; }

/* Карточка комментария */
.card {
  display: grid; grid-template-columns: 56px 1fr; gap: 14px;
  padding: 14px 16px; margin-bottom: 8px;
  transition: opacity .25s, border-color .12s;
}
.card:hover { border-color: var(--border-strong); }
.card.gone { opacity: 0; }
.thumb { width: 56px; height: 72px; border-radius: 6px; overflow: hidden; display: block; background: 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: 14px; font-weight: 600; }
.btn.dm { padding: 0 8px; font-size: 12px; align-self: center; }
.nick { color: inherit; text-decoration: none; }
.nick:hover { text-decoration: underline; }
.badge { border-radius: 5px; padding: 1px 7px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.badge.kw { background: var(--warn-bg); color: var(--warn-text); }
.card .text { margin: 5px 0 5px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.45; }
.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: 2px solid var(--border-strong);
  background: var(--surface-2); border-radius: 0 6px 6px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.reply-shown small { display: block; color: var(--muted); margin-top: 2px; }
.reply-shown.dm-shown { border-left-color: var(--accent); }
.tip {
  position: fixed; z-index: 1000; width: max-content; max-width: 280px; padding: 6px 10px; border-radius: 6px;
  background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 4px 14px rgb(0 0 0 / .18); pointer-events: none;
}
.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: 5px 8px; font-size: 14px; }
.actions .spacer { flex: 1; }

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

/* Массовый ответ */
.pick { width: 16px; height: 16px; margin: 0 2px 0 0; accent-color: var(--accent); align-self: center; cursor: pointer; }
.radios { display: grid; gap: 6px; margin-bottom: 12px; }
.radio { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; cursor: pointer; font-weight: 400; }
.radio input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.panel.bulk label > textarea { margin-top: 4px; color: var(--text); font-weight: 400; }
.verify { border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--border); border-left-width: 3px; }
.verify.good { border-left-color: var(--ok); }
.verify.bad { border-left-color: var(--danger); }
.verify.bad > b { color: var(--danger); }
.verify ul { margin: 6px 0 8px; padding-left: 20px; font-size: 14px; color: var(--muted); }
.verify td { font-size: 13px; }
.job-inline { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.job-inline progress { width: 140px; height: 6px; flex: none; accent-color: var(--accent); }
.bulk-preview { margin-top: 10px; }
.bulk-preview .reply-shown { margin-top: 6px; }
.panel.job { padding: 12px 16px; border-left: 3px solid var(--accent); }
.panel.job.paused { border-left-color: var(--warn-text); }
.panel.job.done, .panel.job.canceled { border-left-color: var(--border-strong); }
.job-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.job-head b { font-weight: 600; }
.job-head .spacer { flex: 1; }
.panel.job progress { width: 100%; height: 6px; margin: 10px 0 6px; accent-color: var(--accent); }
.job-stats { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-note { margin-top: 6px; font-size: 14px; color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; padding: 6px 10px; }

/* Диалоги */
.dialogs { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.dlg-list { min-width: 0; }
.dlg-list .toolbar input { max-width: none; }
.dlg-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; margin-bottom: 6px;
}
.dlg-row .avatar { width: 34px; height: 34px; font-size: 13px; }
.dlg-row:hover { border-color: var(--border-strong); }
.dlg-row.active { border-color: var(--text); }
.dlg-row-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dlg-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.dlg-row-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.dlg-row-top .hint { flex: none; font-size: 12px; }
.dlg-row-text { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dlg-thread { padding: 14px 16px; position: sticky; top: 14px; }
.thread { display: grid; gap: 10px; }
.thread-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.thread-head b { font-weight: 600; }
.thread-head .back { display: none; }
.thread-log { display: flex; flex-direction: column; gap: 5px; max-height: min(58vh, 640px); overflow-y: auto; padding: 4px 2px; }
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.bubble { max-width: 76%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.bubble small { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }

/* Настройки */
.panel { padding: 18px 20px; margin-bottom: 12px; }
.panel h2 { font-size: 16px; font-weight: 600; 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; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
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); box-shadow: 0 1px 0 var(--border); }
.table-scroll td, .table-scroll th { padding-left: 12px; padding-right: 12px; }
.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-strong); }

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

@media (max-width: 820px) {
  .dialogs { grid-template-columns: 1fr; }
  .dialogs.has-open .dlg-list { display: none; }
  .dialogs:not(.has-open) .dlg-thread { display: none; }
  .dlg-thread { position: static; }
  .thread-head .back { display: inline-block; }
}

/* На телефоне боковая панель становится нижней */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .logo, .side-spacer, .side-me { display: none; }
  .page-head { padding: 16px 16px 2px; }
  .page-head h1 { font-size: 19px; }
  .banner { padding: 0 16px; }
  main { padding: 12px 16px 88px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; }
  #toast { bottom: 76px; }
}
@media (max-width: 560px) {
  .card { grid-template-columns: 1fr; }
  .thumb { display: none; }
  .toolbar { flex-wrap: wrap; }
}
