/* BlackSea Rockfishing — Telegram Mini App SPA.
   Тёмная «морская» палитра, задаётся принудительно независимо от themeParams:
   фон #0b1520/#0f1e2b, карточки #13293a, акцент #2e9e6b (морская зелень),
   текст #e8f1f6, приглушённый #8fa8b8. Системные шрифты, без внешних ресурсов. */

:root {
  --bg: #0b1520;
  --bg-elev: #0f1e2b;
  --card: #13293a;
  --card-2: #10222f;
  --accent: #2e9e6b;
  --accent-press: #26875a;
  --danger: #d9534f;
  --danger-press: #b94643;
  --text: #e8f1f6;
  --muted: #8fa8b8;
  --line: #1d3648;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PT Sans", "Open Sans", sans-serif;
}

* { box-sizing: border-box; }

/* Component display declarations must never override the semantic hidden state. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Шапка ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 2px 8px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand__logo { width: 40px; height: 20px; flex: 0 0 auto; }

.brand__text { display: flex; flex-direction: column; min-width: 0; }

.brand__title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  color: var(--text);
}

.brand__sub { font-size: 11px; color: var(--muted); }

.topbar__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
  max-width: 220px;
  margin-left: auto;
}

.channel-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.channel-picker__label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.channel-picker__select-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.channel-picker__select {
  width: 100%;
  max-width: 170px;
  min-height: 30px;
  padding: 5px 27px 5px 9px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(46, 158, 107, .55);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.channel-picker__select:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.channel-picker__select:disabled { opacity: .6; cursor: wait; }

.channel-picker__chevron {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 10px;
  height: 7px;
  color: var(--accent);
  transform: translateY(-50%);
  pointer-events: none;
}

.chips { display: flex; justify-content: flex-end; gap: 6px; flex: 0 0 auto; }

.chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.chip--mode { color: var(--accent); border-color: rgba(46, 158, 107, .45); }

/* ---------- Дев-режим ---------- */

.devbar {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.devbar__label { font-size: 12px; color: var(--muted); }

.devbar__input {
  flex: 1 1 120px;
  min-width: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font: inherit;
}

.devbar__hint {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Вкладки ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  margin: 4px 0 12px;
  position: sticky;
  top: 4px;
  z-index: 5;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tabs__btn {
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tabs__btn[aria-selected="true"] {
  background: var(--accent);
  color: #06120c;
}

.tabs__btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Контент ---------- */

.content { flex: 1 1 auto; display: flex; flex-direction: column; }

.view__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.view__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.view__hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.view__tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.empty {
  margin: 18px 0;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---------- Кнопки ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--card);
  flex: 0 0 auto;
  transition: background .15s, transform .05s;
}

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--accent { background: var(--accent); color: #06120c; }
.btn--accent:hover:not(:disabled) { background: var(--accent-press); }

.btn--ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--card-2); }

.btn--danger { background: transparent; border-color: rgba(217, 83, 79, .55); color: #e79390; }
.btn--danger:hover:not(:disabled) { background: rgba(217, 83, 79, .14); }

.btn--sm { padding: 6px 10px; font-size: 12px; }

.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Карточки отчётов ---------- */

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card__meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.card__source { color: #7fc7e8; text-decoration: none; border-bottom: 1px dashed rgba(127, 199, 232, .5); }

.card__id { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge--new       { color: #9db7c6; background: rgba(143, 168, 184, .12); border-color: rgba(143, 168, 184, .35); }
.badge--queued    { color: #7fc7e8; background: rgba(127, 199, 232, .1); border-color: rgba(127, 199, 232, .35); }
.badge--approved  { color: #6fd39a; background: rgba(46, 158, 107, .12); border-color: rgba(46, 158, 107, .45); }
.badge--rejected  { color: #e79390; background: rgba(217, 83, 79, .1); border-color: rgba(217, 83, 79, .4); }
.badge--published { color: #b7a36b; background: rgba(183, 163, 107, .1); border-color: rgba(183, 163, 107, .4); }
.badge--postponed { color: #c3a8d6; background: rgba(195, 168, 214, .1); border-color: rgba(195, 168, 214, .35); }
.badge--video     { color: #8fd0e8; background: rgba(80, 170, 200, .12); border-color: rgba(80, 170, 200, .4); }
.card__video video { width: 100%; max-width: 420px; border-radius: 10px; background: #000; }

.card__photos { margin-bottom: 10px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.photo-item {
  position: relative;
  margin: 0;
  border: 0;
  padding: 0;
  background: var(--card-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.photo-item__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: zoom-in;
}

.photo-item__preview:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.photo-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item__select {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  z-index: 2;
}

.photo-item__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.photo-item__check {
  position: absolute;
  inset: 0;
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(232, 241, 246, .8);
  background: rgba(11, 21, 32, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-item__check svg { width: 12px; height: 12px; opacity: 0; }

.photo-item__input:focus-visible + .photo-item__check {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.photo-item.selected .photo-item__check {
  background: var(--accent);
  border-color: var(--accent);
}

.photo-item.selected .photo-item__check svg { opacity: 1; }

.photo-item__num {
  position: absolute;
  bottom: 4px; right: 6px;
  font-size: 10px;
  color: var(--text);
  background: rgba(11, 21, 32, .6);
  border-radius: 4px;
  padding: 1px 5px;
}

.photo-hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); }

/* ---------- Редактор подписи ---------- */

.caption-wrap { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Варианты заголовка поста ---------- */

.title-wrap { display: flex; flex-direction: column; gap: 6px; }
.title-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.title-chips .chip { cursor: pointer; font-size: 12px; padding: 5px 10px; }
.title-chips .chip:active { transform: scale(.97); }
.chip--on { color: var(--accent); border-color: rgba(46, 158, 107, .55); background: rgba(46, 158, 107, .12); }
.title-input {
  flex: 1 1 100%;
  min-width: 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 12px;
}

.caption-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.caption {
  width: 100%;
  min-height: 150px;
  height: 150px;
  resize: vertical;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px;
}

.caption:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* ---------- Действия ---------- */

.card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.card__actions .btn--span2 { grid-column: span 2; }

@media (min-width: 480px) {
  .card__actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card__actions .btn--span2 { grid-column: span 2; }
}

.card__schedule {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Запланировано: два «фрейма-пилюли» в шапке карточки.
   Дата прижата влево, отсчёт - вправо, как чипы статуса. */
.card__schedule-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  /* Отступы со всех сторон: не слить с шапкой и не касаться фото ниже. */
  margin: 10px 12px 12px;
}
.card__schedule-when,
.card__schedule-countdown {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: #12212f;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}
.card__schedule-countdown {
  color: #4ad295;
  font-weight: 400;
}
@media (max-width: 420px) {
  .card__schedule-when { overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Источники ---------- */

.addform {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.addform__input, .addform__select {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
}

.addform__input { flex: 1 1 200px; }
.addform__input--title { flex: 1 1 140px; }
.addform__select { flex: 0 0 130px; }

.addform__hint { margin: 0 0 12px; font-size: 11px; color: var(--muted); }

.tablewrap {
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 560px; }

.table th, .table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.table tbody tr:last-child td { border-bottom: 0; }

.src-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.src-url { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

.src-controls { display: flex; flex-direction: column; gap: 4px; }

.src-controls input[type="text"], .src-controls select {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 7px;
  font: inherit;
  font-size: 12px;
  width: 100%;
  min-width: 110px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
  flex: 0 0 auto;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch__track {
  position: absolute;
  inset: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background .15s;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}

.switch input:checked + .switch__track { background: rgba(46, 158, 107, .35); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--text); outline-offset: 2px; }

.src-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.src-last { font-size: 11px; color: var(--muted); white-space: nowrap; }
.src-last.ok { color: var(--accent); }
.src-last.err { color: #e79390; }

.src-error { color: #e79390; font-size: 11px; overflow-wrap: anywhere; max-width: 220px; }

.table__actions { width: 1%; white-space: nowrap; }

/* ---------- Результаты сканирования ---------- */

.scanresults {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.scanresults__title { margin: 0 0 6px; font-size: 13px; font-weight: 700; }

.scanresults__total { margin: 0 0 8px; font-size: 12px; color: var(--muted); }

.scanresults__list { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; }

.scanresults__item {
  font-size: 12px;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scanresults__item .scan-name { font-weight: 600; overflow-wrap: anywhere; }
.scanresults__item .scan-stats { color: var(--muted); }
.scanresults__item.is-error { border-color: rgba(217, 83, 79, .45); }
.scanresults__item .scan-error { color: #e79390; overflow-wrap: anywhere; }

/* ---------- Диалог планирования ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, .72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 12px;
}

@media (min-width: 480px) { .overlay { align-items: center; } }

.dialog {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  max-height: 86vh;
  overflow-y: auto;
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.dialog__title { margin: 0; font-size: 15px; font-weight: 700; }

.dialog__close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.dialog__close:hover { color: var(--text); background: var(--card-2); }

.dialog__meta { margin: 0 0 10px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }

.field__label { font-size: 11px; color: var(--muted); font-weight: 600; }

.field__input {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  color-scheme: dark;
}

.slots { display: flex; flex-wrap: wrap; gap: 6px; }

.slots__empty { font-size: 12px; color: var(--muted); }

.slot {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.slot:hover { border-color: var(--accent); color: var(--accent); }
.slot.is-active { background: var(--accent); color: #06120c; border-color: var(--accent); }

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, .92);
  display: flex;
  align-items: center;
  justify-content:center;
  z-index: 80;
  padding: 16px;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(11, 21, 32, .8);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(92vw, 480px);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  overflow-wrap: anywhere;
}

.toast.is-error { border-left-color: var(--danger); }

/* ---------- Загрузка ---------- */

.loading {
  margin: 14px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.loading::after {
  content: "";
  display: block;
  width: 22px; height: 22px;
  margin: 8px auto 0;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn--loading::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 7px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}

/* ---------- Футер ---------- */

.footer { margin-top: 18px; }

.footer__wave { width: 100%; height: 12px; display: block; opacity: .6; }

/* ---------- Мелкие экраны ---------- */

@media (max-width: 440px) {
  .topbar__controls { max-width: 205px; }
  .channel-picker { width: 100%; }
  .channel-picker__label { display: none; }
  .channel-picker__select-wrap { width: 100%; }
  .channel-picker__select { max-width: none; }
  .chips { flex-wrap: wrap; row-gap: 4px; }
}

@media (max-width: 359px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls {
    flex: 1 1 100%;
    max-width: none;
    align-items: stretch;
    margin-left: 50px;
  }
  .chips { justify-content: flex-start; }
  .card__actions { grid-template-columns: 1fr; }
  .card__actions .btn--span2 { grid-column: span 1; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .tabs__btn { font-size: 12px; padding: 8px 2px; }
}

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

/* Поле «Автор» в карточке отчёта */
.author-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border, #2a3b33);
  border-radius: 8px;
  background: var(--card, #0d1a14);
  color: inherit;
  font: inherit;
}
.author-input:focus {
  outline: none;
  border-color: var(--accent, #4fd1a5);
}

/* Кнопка «Перевести» + счётчик в шапке подписи */
.caption-label__tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.caption-label__tools .btn {
  min-height: 26px;
  padding: 2px 10px;
}
/* Чип статуса нейросетей в топбаре */
.chip--warn {
  color: #ffb454;
  border-color: rgba(255, 180, 84, 0.45);
}

/* Выпадающий список нейросетей (чип в топбаре) */
.llm-menu {
  position: relative;
  display: inline-flex;
}
.chip--btn {
  cursor: pointer;
  font: inherit;
}
.llm-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 280px;
  background: #101c29;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.llm-dropdown__head {
  font-weight: 600;
  margin-bottom: 6px;
}
.llm-dropdown__body p {
  margin: 4px 0;
  color: #9fb3c8;
}
.llm-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.llm-row__text {
  line-height: 1.35;
}
.llm-row__text small {
  color: #9fb3c8;
}
.llm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
}
.llm-ok {
  background: #2e9e6b;
}
.llm-down {
  background: #c0554d;
}

/* Свой промт для описания фото: мини-попап */
.prompt-pop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.prompt-pop__box {
  width: min(440px, 92vw);
  background: #101c29;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.prompt-pop__head {
  font-weight: 600;
  margin-bottom: 8px;
}
.prompt-pop__input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  background: #0b1420;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.prompt-pop__hint {
  margin-top: 6px;
  font-size: 12px;
  color: #9fb3c8;
}
.prompt-pop__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chip--sm {
  padding: 2px 9px;
}


/* ---------- Полировка интерфейса v12 ---------- */
:root {
  --radius: 14px;
  --radius-sm: 9px;
  --control-h: 40px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

button, input, select, textarea { -webkit-tap-highlight-color: transparent; }

#app {
  padding-inline: clamp(10px, 3vw, 16px);
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  align-items: center;
  gap: 12px;
  padding: 12px 2px 10px;
}
.brand__logo { width: 42px; height: 22px; }
.brand__title { font-size: 17px; line-height: 1.2; }
.brand__sub { margin-top: 2px; font-size: 11px; }
.topbar__controls { gap: 6px; max-width: 245px; }
.channel-picker__select { min-height: 34px; padding-inline: 12px 30px; font-size: 12px; }
.chips { align-items: center; gap: 5px; }
.chip { min-height: 28px; display: inline-flex; align-items: center; justify-content: center; }

.tabs {
  top: max(4px, env(safe-area-inset-top, 0px));
  gap: 3px;
  margin: 4px 0 16px;
  padding: 4px;
  background: rgba(15, 30, 43, .96);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .2);
  backdrop-filter: blur(10px);
}
.tabs__btn { min-height: 42px; padding: 9px 12px; font-size: 13px; }
.tabs__btn[aria-selected="true"] { box-shadow: 0 3px 10px rgba(46, 158, 107, .24); }

.view__head { min-height: 42px; margin-bottom: 6px; }
.view__title { font-size: 18px; letter-spacing: -.1px; }
.view__hint { margin-bottom: 12px; line-height: 1.45; }
.view__tools { gap: 6px; margin-bottom: 10px; }
.view__tools .btn { flex: 1 1 auto; }

.btn {
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  text-align: center;
  transition: background .15s, border-color .15s, color .15s, transform .05s, opacity .15s;
}
.btn--sm { min-height: 36px; padding: 7px 11px; }
.btn--accent { box-shadow: 0 4px 12px rgba(46, 158, 107, .18); }
.btn--ghost { background: rgba(16, 34, 47, .86); }
.btn--refresh { min-width: 96px; }

.cards { gap: 14px; }
.card {
  padding: 14px;
  border-color: rgba(49, 79, 98, .72);
  box-shadow: 0 7px 22px rgba(0, 0, 0, .23);
}
.card__head { align-items: center; margin-bottom: 10px; }
.card__meta { line-height: 1.55; }
.badge { padding: 4px 9px; }
.card__video { margin-bottom: 10px; }
.card__video video { max-width: 100%; }
.card__photos { margin-bottom: 12px; }
.photo-grid { gap: 7px; }
.photo-item { border: 1px solid rgba(255, 255, 255, .04); }
.photo-hint { margin-top: 7px; }

.title-wrap, .caption-wrap { gap: 7px; margin-top: 11px; }
.title-chips { gap: 6px; }
.title-chips .chip { min-height: 34px; padding: 6px 11px; }
.caption-label { align-items: center; gap: 8px; min-height: 30px; }
.caption-label > span:first-child { flex: 0 0 auto; }
.caption-label__tools {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
  flex-wrap: wrap;
}
.caption-label__tools .btn { min-height: 34px; padding: 6px 10px; }
.caption-label__tools .chip--sm { min-width: 34px; min-height: 34px; padding: 4px 9px; }
.caption-count { margin-left: 2px; white-space: nowrap; }
.caption, .author-input {
  border-color: rgba(49, 79, 98, .9);
  background: rgba(13, 29, 41, .92);
}
.caption { padding: 12px; line-height: 1.55; }
.author-input { min-height: var(--control-h); margin-top: 0; padding: 9px 11px; }

.card__actions { gap: 8px; margin-top: 12px; }
.card__actions .btn { width: 100%; min-width: 0; }
.card__schedule { grid-column: 1 / -1; margin: 4px 0 0; align-self: center; }

.addform {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 140px auto;
  gap: 8px;
  padding: 12px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.addform__input, .addform__select { min-height: var(--control-h); width: 100%; }
.addform__input, .addform__input--title, .addform__select { flex: none; }
.addform__hint { margin-bottom: 14px; padding-inline: 2px; }
.tablewrap { box-shadow: 0 6px 18px rgba(0, 0, 0, .17); }
.table th, .table td { padding: 10px 11px; vertical-align: middle; }
.table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.src-title { line-height: 1.35; }
.src-url { display: inline-block; margin-top: 3px; }
.switch { width: 42px; height: 24px; }
.switch__track::after { width: 18px; height: 18px; }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.src-actions .btn { min-height: 32px; padding: 5px 9px; }

.dialog, .prompt-pop__box { border-radius: 16px; padding: 16px; }
.dialog__actions, .prompt-pop__actions { gap: 8px; }
.prompt-pop__input { min-height: 110px; padding: 11px; line-height: 1.45; }
.llm-dropdown { width: min(320px, calc(100vw - 24px)); border-radius: 13px; padding: 12px 14px; }
.toast { width: max-content; padding: 11px 15px; line-height: 1.35; }

@media (max-width: 620px) {
  .addform { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .addform__input:first-child { grid-column: 1 / -1; }
  .addform .btn { width: 100%; }
}

@media (max-width: 440px) {
  #app { padding-inline: 10px; }
  .topbar { align-items: flex-start; gap: 8px; }
  .brand { gap: 7px; padding-top: 2px; }
  .brand__logo { width: 34px; height: 18px; }
  .brand__title { font-size: 15px; }
  .brand__sub { font-size: 10px; }
  .topbar__controls { max-width: min(250px, calc(100vw - 125px)); }
  .chips { width: 100%; justify-content: flex-end; }
  .chip { font-size: 10.5px; }
  .tabs { margin-bottom: 14px; }
  .tabs__btn { min-height: 40px; font-size: 12.5px; }
  .view__title { font-size: 17px; }
  .view__tools { display: grid; grid-template-columns: 1fr 1fr; }
  .view__tools .btn:first-child { grid-column: 1 / -1; }
  .card { padding: 12px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caption-label { align-items: flex-start; flex-direction: column; }
  .caption-label__tools { width: 100%; justify-content: flex-start; }
  .caption-label__tools .btn { flex: 1 1 auto; }
  .caption-label__tools .chip--sm { flex: 0 0 34px; }
  .caption-count { margin-left: auto; align-self: center; }
  .card__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card__actions .btn { min-height: 46px; }
  .addform { grid-template-columns: 1fr; padding: 10px; }
  .addform__input:first-child { grid-column: auto; }
  .table { min-width: 530px; }
  .dialog__actions, .prompt-pop__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dialog__actions .btn, .prompt-pop__actions .btn { width: 100%; }
}

@media (max-width: 359px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls { margin-left: 41px; max-width: none; }
  .view__tools { grid-template-columns: 1fr; }
  .view__tools .btn:first-child { grid-column: auto; }
  .caption-label__tools .btn { flex: 1 1 100%; }
  .card__actions { grid-template-columns: 1fr; }
}
.card__badges { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
@media (max-width: 440px) {
  .card__head { align-items: flex-start; }
  .card__meta { min-width: 0; flex: 1 1 auto; }
  .card__badges { flex: 0 0 auto; max-width: 42%; }
}

@media (max-width: 440px) {
  .topbar__controls { flex: 1 1 0; width: auto; max-width: none; }
}

/* ---------- UI audit refinements v13 ---------- */
html { min-height: 100%; }
body { min-height: 100%; }
#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Combined filter state: JS keeps btn--ghost while toggling btn--accent. */
.btn.btn--ghost.btn--accent {
  background: var(--accent);
  border-color: transparent;
  color: #06120c;
}
.btn.btn--ghost.btn--accent:hover:not(:disabled) { background: var(--accent-press); }

.chip, .title-input { font-family: inherit; line-height: 1.2; }
.badge--type {
  color: #9db7c6;
  background: rgba(143, 168, 184, .12);
  border-color: rgba(143, 168, 184, .35);
}

.card__head { align-items: flex-start; }
.card__badges { gap: 6px; }
.card__actions .btn--span2 { grid-column: auto; }
.card__actions [data-act="republish"] { grid-column: 1 / -1; }
.card__actions [data-act="archive-delete"] { grid-column: 1 / -1; }
.card > .card__schedule { margin: 9px 0 0; grid-column: auto; }
.card__actions > .card__schedule { grid-column: 1 / -1; margin: 0; }

.author-input,
.field__input,
.devbar__input,
.addform__input,
.addform__select,
.src-controls input[type="text"],
.src-controls select {
  min-height: var(--control-h);
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--text);
  font-family: inherit;
}
.src-controls select { width: 100%; min-width: 110px; padding: 7px; }
:where(.author-input, .title-input, .field__input, .devbar__input, .addform__input, .addform__select, .src-controls input[type="text"], .src-controls select, .prompt-pop__input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.src-actions .btn { min-height: 36px; }
.chip--btn { min-height: 34px; font-size: 11px; }
.dialog__close { width: 40px; height: 40px; padding: 0; }
.lightbox__close { width: 40px; height: 40px; }
.photo-item__select { width: 40px; height: 40px; top: 0; left: 0; }
.photo-item__check { inset: 6px auto auto 6px; width: 22px; height: 22px; }

.dialog, .prompt-pop__box, .llm-dropdown { border-radius: var(--radius); }
.card__video video, .prompt-pop__input { border-radius: var(--radius-sm); }
.llm-dropdown, .prompt-pop__box { background: var(--bg-elev); border-color: var(--line); }
.prompt-pop {
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(4, 10, 16, .72);
}
.prompt-pop__box, .dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
.prompt-pop__head, .dialog__title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.prompt-pop__input { background: var(--card-2); color: var(--text); border-color: var(--line); }
.llm-dropdown__body p, .llm-row__text small, .prompt-pop__hint { color: var(--muted); }
.llm-ok { background: var(--accent); }
.llm-down { background: var(--danger); }

/* Source list becomes readable cards on phones; desktop table is unchanged. */
@media (max-width: 600px) {
  .tablewrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .table { min-width: 0; border-collapse: separate; }
  .table thead { display: none; }
  .table, .table tbody { display: block; width: 100%; }
  .table tbody { display: flex; flex-direction: column; gap: 10px; }
  .table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 12px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .17);
  }
  .table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .table tbody td:first-child,
  .table tbody td.table__actions { grid-column: 1 / -1; }
  .table tbody td:first-child { display: block; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .table tbody td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .35px;
  }
  .table tbody td:nth-child(4), .table tbody td:nth-child(5) { grid-column: 1 / -1; }
  .table tbody td.table__actions { padding-top: 8px; border-top: 1px solid var(--line); }
  .src-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .src-actions .btn { width: 100%; }
  .src-controls { width: 100%; }
  .src-last, .src-error { text-align: right; }
}

@media (min-width: 620px) {
  .card__actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Cross-source duplicate variants v17 ---------- */
body.dialog-open { overflow: hidden; }
.duplicates-link {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid rgba(46, 158, 107, .55);
  border-radius: 999px;
  background: rgba(46, 158, 107, .12);
  color: #78d7a4;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.duplicates-link:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.duplicates-dialog {
  display: flex;
  flex-direction: column;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.duplicates-head { flex: 0 0 auto; }
.duplicates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 8px;
}
.variant-row {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  cursor: pointer;
}
.variant-row.is-representative { border-color: rgba(46, 158, 107, .65); }
.variant-row > input { position: absolute; opacity: 0; }
.variant-radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--card-2);
}
.variant-row > input:checked + .variant-radio { background: var(--accent); border-color: var(--accent); }
.variant-row > input:focus-visible + .variant-radio { outline: 2px solid var(--text); outline-offset: 3px; }
.variant-row > input:disabled + .variant-radio { opacity: .45; }
.variant-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.variant-title { font-weight: 700; overflow-wrap: anywhere; }
.variant-author, .variant-meta { color: var(--muted); font-size: 11px; }
.variant-source { width: fit-content; color: #7fc7e8; font-size: 12px; }
.variant-badge {
  align-self: start;
  padding: 3px 7px;
  border-radius: 999px;
  color: #78d7a4;
  background: rgba(46, 158, 107, .14);
  font-size: 10px;
  font-weight: 700;
}
.duplicates-reason {
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px solid rgba(183, 163, 107, .4);
  border-radius: var(--radius-sm);
  background: rgba(183, 163, 107, .1);
  color: #d2c184;
  font-size: 12px;
}
.duplicates-actions { flex: 0 0 auto; padding-top: 10px; border-top: 1px solid var(--line); }

@media (max-width: 479px) {
  .overlay--sheet { padding: 0; }
  .duplicates-dialog {
    max-width: none;
    max-height: min(88dvh, 760px);
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding: 14px 12px max(14px, env(safe-area-inset-bottom, 0px));
  }
  .variant-row { min-height: 76px; grid-template-columns: 24px minmax(0, 1fr); }
  .variant-badge { grid-column: 2; justify-self: start; }
  .duplicates-actions { display: grid; grid-template-columns: 1fr 1.25fr; }
  .duplicates-actions .btn { min-height: 48px; }
}

@media (max-width: 440px) {
  .caption-wrap > .caption-label { align-items: flex-start; flex-direction: column; }
  .title-wrap > .caption-label { align-items: center; flex-direction: row; }
  .view__tools > .btn--accent { grid-column: 1 / -1; }
  .view__tools .btn:first-child:not(.btn--accent) { grid-column: auto; }
  .card__actions .btn { min-height: 44px; }
  .card__badges { max-width: 45%; }
}

@media (max-width: 379px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
    align-items: stretch;
  }
  .chips { justify-content: flex-end; }
}

/* Compact source rows and platform filter pills. */
.source-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 10px;
}
.source-filter {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .035);
  color: var(--muted);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.source-filter:hover {
  border-color: rgba(46, 158, 107, .5);
  color: var(--text);
}
.source-filter.is-active {
  border-color: rgba(46, 158, 107, .72);
  background: rgba(46, 158, 107, .16);
  color: #dff8ec;
}
.source-filter span {
  margin-left: 4px;
  color: inherit;
  opacity: .7;
}
#sources-table th,
#sources-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}
#sources-table .src-title {
  margin-bottom: 1px;
  line-height: 1.15;
}
#sources-table .src-url,
#sources-table .src-last {
  line-height: 1.2;
}
#sources-table .btn--sm {
  min-height: 28px;
  padding: 5px 8px;
}

@media (max-width: 600px) {
  .source-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: -2px;
    padding: 2px;
  }
  .source-filters::-webkit-scrollbar { display: none; }
  .source-filter { flex: 0 0 auto; }
  #sources-table tbody tr {
    padding: 9px 10px;
    gap: 5px 10px;
  }
  #sources-table tbody td {
    min-height: 24px;
    padding: 3px 0;
  }
}

/* Extra-compact mobile source cards: keep information, remove empty height. */
@media (max-width: 600px) {
  #sources-table tbody {
    gap: 7px;
  }
  #sources-table tbody tr {
    row-gap: 2px;
    column-gap: 8px;
    padding: 7px 9px;
    border-radius: 14px;
  }
  #sources-table tbody td {
    min-height: 20px;
    padding: 1px 0;
    gap: 6px;
  }
  #sources-table tbody td:first-child {
    padding-bottom: 4px;
  }
  #sources-table .src-title {
    font-size: 13px;
    line-height: 1.15;
  }
  #sources-table .src-url {
    margin-top: 0;
    font-size: 11px;
    line-height: 1.15;
  }
  #sources-table tbody td[data-label]::before {
    font-size: 9px;
    line-height: 1;
  }
  #sources-table tbody td:nth-child(4) {
    min-height: 22px;
  }
  #sources-table tbody td.source-error-empty {
    display: none;
  }
  #sources-table tbody td.table__actions {
    padding-top: 5px;
    margin-top: 2px;
  }
  #sources-table .src-actions {
    gap: 6px;
  }
  #sources-table .src-actions .btn {
    min-height: 30px;
    padding: 5px 8px;
  }
}

.scanresults__item.is-warning { border-color: rgba(224, 169, 73, .58); }
.scan-history { color: #9fd4e9; font-size: 12px; }
.scan-warning { color: #e3b96d; font-size: 12px; overflow-wrap: anywhere; }
.src-last.warn { color: #e3b96d; }

.card__head-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 7px; flex: 0 0 auto; }
.card__top-reject { min-width: 0; padding: 5px 9px; line-height: 1.15; }
@media (max-width: 720px) {
  .card__head-actions { flex-direction: column-reverse; align-items: flex-end; gap: 5px; max-width: 46%; }
  .card__top-reject { font-size: 11px; }
}

/* restored after deploy merge */
/* BlackSea Rockfishing — Telegram Mini App SPA.
   Тёмная «морская» палитра, задаётся принудительно независимо от themeParams:
   фон #0b1520/#0f1e2b, карточки #13293a, акцент #2e9e6b (морская зелень),
   текст #e8f1f6, приглушённый #8fa8b8. Системные шрифты, без внешних ресурсов. */

:root {
  --bg: #0b1520;
  --bg-elev: #0f1e2b;
  --card: #13293a;
  --card-2: #10222f;
  --accent: #2e9e6b;
  --accent-press: #26875a;
  --danger: #d9534f;
  --danger-press: #b94643;
  --text: #e8f1f6;
  --muted: #8fa8b8;
  --line: #1d3648;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PT Sans", "Open Sans", sans-serif;
}

* { box-sizing: border-box; }

/* Component display declarations must never override the semantic hidden state. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Шапка ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 2px 8px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand__logo { width: 40px; height: 20px; flex: 0 0 auto; }

.brand__text { display: flex; flex-direction: column; min-width: 0; }

.brand__title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  color: var(--text);
}

.brand__sub { font-size: 11px; color: var(--muted); }

.topbar__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
  max-width: 220px;
  margin-left: auto;
}

.channel-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.channel-picker__label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.channel-picker__select-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.channel-picker__select {
  width: 100%;
  max-width: 170px;
  min-height: 30px;
  padding: 5px 27px 5px 9px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(46, 158, 107, .55);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.channel-picker__select:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.channel-picker__select:disabled { opacity: .6; cursor: wait; }

.channel-picker__chevron {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 10px;
  height: 7px;
  color: var(--accent);
  transform: translateY(-50%);
  pointer-events: none;
}

.chips { display: flex; justify-content: flex-end; gap: 6px; flex: 0 0 auto; }

.chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.chip--mode { color: var(--accent); border-color: rgba(46, 158, 107, .45); }

/* ---------- Дев-режим ---------- */

.devbar {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.devbar__label { font-size: 12px; color: var(--muted); }

.devbar__input {
  flex: 1 1 120px;
  min-width: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font: inherit;
}

.devbar__hint {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Вкладки ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  margin: 4px 0 12px;
  position: sticky;
  top: 4px;
  z-index: 5;
}

.tabs__btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tabs__btn[aria-selected="true"] {
  background: var(--accent);
  color: #06120c;
}

.tabs__btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Контент ---------- */

.content { flex: 1 1 auto; display: flex; flex-direction: column; }

.view__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.view__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.view__hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.view__tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.empty {
  margin: 18px 0;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---------- Кнопки ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--card);
  flex: 0 0 auto;
  transition: background .15s, transform .05s;
}

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--accent { background: var(--accent); color: #06120c; }
.btn--accent:hover:not(:disabled) { background: var(--accent-press); }

.btn--ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--card-2); }

.btn--danger { background: transparent; border-color: rgba(217, 83, 79, .55); color: #e79390; }
.btn--danger:hover:not(:disabled) { background: rgba(217, 83, 79, .14); }

.btn--sm { padding: 6px 10px; font-size: 12px; }

.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Карточки отчётов ---------- */

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card__meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.card__source { color: #7fc7e8; text-decoration: none; border-bottom: 1px dashed rgba(127, 199, 232, .5); }

.card__id { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge--new       { color: #9db7c6; background: rgba(143, 168, 184, .12); border-color: rgba(143, 168, 184, .35); }
.badge--queued    { color: #7fc7e8; background: rgba(127, 199, 232, .1); border-color: rgba(127, 199, 232, .35); }
.badge--approved  { color: #6fd39a; background: rgba(46, 158, 107, .12); border-color: rgba(46, 158, 107, .45); }
.badge--rejected  { color: #e79390; background: rgba(217, 83, 79, .1); border-color: rgba(217, 83, 79, .4); }
.badge--published { color: #b7a36b; background: rgba(183, 163, 107, .1); border-color: rgba(183, 163, 107, .4); }
.badge--postponed { color: #c3a8d6; background: rgba(195, 168, 214, .1); border-color: rgba(195, 168, 214, .35); }
.badge--video     { color: #8fd0e8; background: rgba(80, 170, 200, .12); border-color: rgba(80, 170, 200, .4); }
.card__video video { width: 100%; max-width: 420px; border-radius: 10px; background: #000; }

.card__photos { margin-bottom: 10px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.photo-item {
  position: relative;
  margin: 0;
  border: 0;
  padding: 0;
  background: var(--card-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.photo-item__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: zoom-in;
}

.photo-item__preview:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.photo-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item__select {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  z-index: 2;
}

.photo-item__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.photo-item__check {
  position: absolute;
  inset: 0;
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(232, 241, 246, .8);
  background: rgba(11, 21, 32, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-item__check svg { width: 12px; height: 12px; opacity: 0; }

.photo-item__input:focus-visible + .photo-item__check {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.photo-item.selected .photo-item__check {
  background: var(--accent);
  border-color: var(--accent);
}

.photo-item.selected .photo-item__check svg { opacity: 1; }

.photo-item__num {
  position: absolute;
  bottom: 4px; right: 6px;
  font-size: 10px;
  color: var(--text);
  background: rgba(11, 21, 32, .6);
  border-radius: 4px;
  padding: 1px 5px;
}

.photo-hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); }

/* ---------- Редактор подписи ---------- */

.caption-wrap { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Варианты заголовка поста ---------- */

.title-wrap { display: flex; flex-direction: column; gap: 6px; }
.title-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.title-chips .chip { cursor: pointer; font-size: 12px; padding: 5px 10px; }
.title-chips .chip:active { transform: scale(.97); }
.chip--on { color: var(--accent); border-color: rgba(46, 158, 107, .55); background: rgba(46, 158, 107, .12); }
.title-input {
  flex: 1 1 100%;
  min-width: 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 12px;
}

.caption-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.caption {
  width: 100%;
  min-height: 150px;
  height: 150px;
  resize: vertical;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px;
}

.caption:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* ---------- Действия ---------- */

.card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.card__actions .btn--span2 { grid-column: span 2; }

@media (min-width: 480px) {
  .card__actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card__actions .btn--span2 { grid-column: span 2; }
}

.card__schedule {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Источники ---------- */

.addform {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.addform__input, .addform__select {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
}

.addform__input { flex: 1 1 200px; }
.addform__input--title { flex: 1 1 140px; }
.addform__select { flex: 0 0 130px; }

.addform__hint { margin: 0 0 12px; font-size: 11px; color: var(--muted); }

.tablewrap {
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 560px; }

.table th, .table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.table tbody tr:last-child td { border-bottom: 0; }

.src-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.src-url { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

.src-controls { display: flex; flex-direction: column; gap: 4px; }

.src-controls input[type="text"], .src-controls select {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 7px;
  font: inherit;
  font-size: 12px;
  width: 100%;
  min-width: 110px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
  flex: 0 0 auto;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch__track {
  position: absolute;
  inset: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background .15s;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}

.switch input:checked + .switch__track { background: rgba(46, 158, 107, .35); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--text); outline-offset: 2px; }

.src-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.src-last { font-size: 11px; color: var(--muted); white-space: nowrap; }
.src-last.ok { color: var(--accent); }
.src-last.err { color: #e79390; }

.src-error { color: #e79390; font-size: 11px; overflow-wrap: anywhere; max-width: 220px; }

.table__actions { width: 1%; white-space: nowrap; }

/* ---------- Результаты сканирования ---------- */

.scanresults {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.scanresults__title { margin: 0 0 6px; font-size: 13px; font-weight: 700; }

.scanresults__total { margin: 0 0 8px; font-size: 12px; color: var(--muted); }

.scanresults__list { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; }

.scanresults__item {
  font-size: 12px;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scanresults__item .scan-name { font-weight: 600; overflow-wrap: anywhere; }
.scanresults__item .scan-stats { color: var(--muted); }
.scanresults__item.is-error { border-color: rgba(217, 83, 79, .45); }
.scanresults__item .scan-error { color: #e79390; overflow-wrap: anywhere; }

/* ---------- Диалог планирования ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, .72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 12px;
}

@media (min-width: 480px) { .overlay { align-items: center; } }

.dialog {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  max-height: 86vh;
  overflow-y: auto;
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.dialog__title { margin: 0; font-size: 15px; font-weight: 700; }

.dialog__close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.dialog__close:hover { color: var(--text); background: var(--card-2); }

.dialog__meta { margin: 0 0 10px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }

.field__label { font-size: 11px; color: var(--muted); font-weight: 600; }

.field__input {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  color-scheme: dark;
}

.slots { display: flex; flex-wrap: wrap; gap: 6px; }

.slots__empty { font-size: 12px; color: var(--muted); }

.slot {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.slot:hover { border-color: var(--accent); color: var(--accent); }
.slot.is-active { background: var(--accent); color: #06120c; border-color: var(--accent); }

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, .92);
  display: flex;
  align-items: center;
  justify-content:center;
  z-index: 80;
  padding: 16px;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(11, 21, 32, .8);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(92vw, 480px);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  overflow-wrap: anywhere;
}

.toast.is-error { border-left-color: var(--danger); }

/* ---------- Загрузка ---------- */

.loading {
  margin: 14px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.loading::after {
  content: "";
  display: block;
  width: 22px; height: 22px;
  margin: 8px auto 0;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.prompt-pop__voices { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
.prompt-pop__voices .voice-chip { cursor: pointer; font-size: 12px; padding: 5px 10px; }

.btn--loading::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 7px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}

/* ---------- Футер ---------- */

.footer { margin-top: 18px; }

.footer__wave { width: 100%; height: 12px; display: block; opacity: .6; }

/* ---------- Мелкие экраны ---------- */

@media (max-width: 440px) {
  .topbar__controls { max-width: 205px; }
  .channel-picker { width: 100%; }
  .channel-picker__label { display: none; }
  .channel-picker__select-wrap { width: 100%; }
  .channel-picker__select { max-width: none; }
  .chips { flex-wrap: wrap; row-gap: 4px; }
}

@media (max-width: 359px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls {
    flex: 1 1 100%;
    max-width: none;
    align-items: stretch;
    margin-left: 50px;
  }
  .chips { justify-content: flex-start; }
  .card__actions { grid-template-columns: 1fr; }
  .card__actions .btn--span2 { grid-column: span 1; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .tabs__btn { font-size: 12px; padding: 8px 2px; }
}

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

/* Поле «Автор» в карточке отчёта */
.author-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border, #2a3b33);
  border-radius: 8px;
  background: var(--card, #0d1a14);
  color: inherit;
  font: inherit;
}
.author-input:focus {
  outline: none;
  border-color: var(--accent, #4fd1a5);
}

/* Кнопка «Перевести» + счётчик в шапке подписи */
.caption-label__tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.caption-label__tools .btn {
  min-height: 26px;
  padding: 2px 10px;
}
/* Чип статуса нейросетей в топбаре */
.chip--warn {
  color: #ffb454;
  border-color: rgba(255, 180, 84, 0.45);
}

/* Выпадающий список нейросетей (чип в топбаре) */
.llm-menu {
  position: relative;
  display: inline-flex;
}
.chip--btn {
  cursor: pointer;
  font: inherit;
}
.llm-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 280px;
  background: #101c29;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.llm-dropdown__head {
  font-weight: 600;
  margin-bottom: 6px;
}
.llm-dropdown__body p {
  margin: 4px 0;
  color: #9fb3c8;
}
.llm-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.llm-row__text {
  line-height: 1.35;
}
.llm-row__text small {
  color: #9fb3c8;
}
.llm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
}
.llm-ok {
  background: #2e9e6b;
}
.llm-down {
  background: #c0554d;
}

/* Свой промт для описания фото: мини-попап */
.prompt-pop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.prompt-pop__box {
  width: min(440px, 92vw);
  background: #101c29;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.prompt-pop__head {
  font-weight: 600;
  margin-bottom: 8px;
}
.prompt-pop__input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  background: #0b1420;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.prompt-pop__hint {
  margin-top: 6px;
  font-size: 12px;
  color: #9fb3c8;
}
.prompt-pop__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chip--sm {
  padding: 2px 9px;
}


/* ---------- Полировка интерфейса v12 ---------- */
:root {
  --radius: 14px;
  --radius-sm: 9px;
  --control-h: 40px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

button, input, select, textarea { -webkit-tap-highlight-color: transparent; }

#app {
  padding-inline: clamp(10px, 3vw, 16px);
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  align-items: center;
  gap: 12px;
  padding: 12px 2px 10px;
}
.brand__logo { width: 42px; height: 22px; }
.brand__title { font-size: 17px; line-height: 1.2; }
.brand__sub { margin-top: 2px; font-size: 11px; }
.topbar__controls { gap: 6px; max-width: 245px; }
.channel-picker__select { min-height: 34px; padding-inline: 12px 30px; font-size: 12px; }
.chips { align-items: center; gap: 5px; }
.chip { min-height: 28px; display: inline-flex; align-items: center; justify-content: center; }

.tabs {
  top: max(4px, env(safe-area-inset-top, 0px));
  gap: 3px;
  margin: 4px 0 16px;
  padding: 4px;
  background: rgba(15, 30, 43, .96);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .2);
  backdrop-filter: blur(10px);
}
.tabs__btn { min-height: 42px; padding: 9px 5px; font-size: 13px; }
.tabs__btn[aria-selected="true"] { box-shadow: 0 3px 10px rgba(46, 158, 107, .24); }

.view__head { min-height: 42px; margin-bottom: 6px; }
.view__title { font-size: 18px; letter-spacing: -.1px; }
.view__hint { margin-bottom: 12px; line-height: 1.45; }
.view__tools { gap: 6px; margin-bottom: 10px; }
.view__tools .btn { flex: 1 1 auto; }

.btn {
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  text-align: center;
  transition: background .15s, border-color .15s, color .15s, transform .05s, opacity .15s;
}
.btn--sm { min-height: 36px; padding: 7px 11px; }
.btn--accent { box-shadow: 0 4px 12px rgba(46, 158, 107, .18); }
.btn--ghost { background: rgba(16, 34, 47, .86); }
.btn--refresh { min-width: 96px; }

.cards { gap: 14px; }
.card {
  padding: 14px;
  border-color: rgba(49, 79, 98, .72);
  box-shadow: 0 7px 22px rgba(0, 0, 0, .23);
}
.card__head { align-items: center; margin-bottom: 10px; }
.card__meta { line-height: 1.55; }
.badge { padding: 4px 9px; }
.card__video { margin-bottom: 10px; }
.card__video video { max-width: 100%; }
.card__photos { margin-bottom: 12px; }
.photo-grid { gap: 7px; }
.photo-item { border: 1px solid rgba(255, 255, 255, .04); }
.photo-hint { margin-top: 7px; }

.title-wrap, .caption-wrap { gap: 7px; margin-top: 11px; }
.title-chips { gap: 6px; }
.title-chips .chip { min-height: 34px; padding: 6px 11px; }
.caption-label { align-items: center; gap: 8px; min-height: 30px; }
.caption-label > span:first-child { flex: 0 0 auto; }
.caption-label__tools {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
  flex-wrap: wrap;
}
.caption-label__tools .btn { min-height: 34px; padding: 6px 10px; }
.caption-label__tools .chip--sm { min-width: 34px; min-height: 34px; padding: 4px 9px; }
.caption-count { margin-left: 2px; white-space: nowrap; }
.caption, .author-input {
  border-color: rgba(49, 79, 98, .9);
  background: rgba(13, 29, 41, .92);
}
.caption { padding: 12px; line-height: 1.55; }
.author-input { min-height: var(--control-h); margin-top: 0; padding: 9px 11px; }

.card__actions { gap: 8px; margin-top: 12px; }
.card__actions .btn { width: 100%; min-width: 0; }
.card__schedule { grid-column: 1 / -1; margin: 4px 0 0; align-self: center; }

.addform {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 140px auto;
  gap: 8px;
  padding: 12px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.addform__input, .addform__select { min-height: var(--control-h); width: 100%; }
.addform__input, .addform__input--title, .addform__select { flex: none; }
.addform__hint { margin-bottom: 14px; padding-inline: 2px; }
.tablewrap { box-shadow: 0 6px 18px rgba(0, 0, 0, .17); }
.table th, .table td { padding: 10px 11px; vertical-align: middle; }
.table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.src-title { line-height: 1.35; }
.src-url { display: inline-block; margin-top: 3px; }
.switch { width: 42px; height: 24px; }
.switch__track::after { width: 18px; height: 18px; }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.src-actions .btn { min-height: 32px; padding: 5px 9px; }

.dialog, .prompt-pop__box { border-radius: 16px; padding: 16px; }
.dialog__actions, .prompt-pop__actions { gap: 8px; }
.prompt-pop__input { min-height: 110px; padding: 11px; line-height: 1.45; }
.llm-dropdown { width: min(320px, calc(100vw - 24px)); border-radius: 13px; padding: 12px 14px; }
.toast { width: max-content; padding: 11px 15px; line-height: 1.35; }

@media (max-width: 620px) {
  .addform { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .addform__input:first-child { grid-column: 1 / -1; }
  .addform .btn { width: 100%; }
}

@media (max-width: 440px) {
  #app { padding-inline: 10px; }
  .topbar { align-items: flex-start; gap: 8px; }
  .brand { gap: 7px; padding-top: 2px; }
  .brand__logo { width: 34px; height: 18px; }
  .brand__title { font-size: 15px; }
  .brand__sub { font-size: 10px; }
  .topbar__controls { max-width: min(250px, calc(100vw - 125px)); }
  .chips { width: 100%; justify-content: flex-end; }
  .chip { font-size: 10.5px; }
  .tabs { margin-bottom: 14px; }
  .tabs__btn { min-height: 40px; font-size: 12.5px; }
  .view__title { font-size: 17px; }
  .view__tools { display: grid; grid-template-columns: 1fr 1fr; }
  .view__tools .btn:first-child { grid-column: 1 / -1; }
  .card { padding: 12px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caption-label { align-items: flex-start; flex-direction: column; }
  .caption-label__tools { width: 100%; justify-content: flex-start; }
  .caption-label__tools .btn { flex: 1 1 auto; }
  .caption-label__tools .chip--sm { flex: 0 0 34px; }
  .caption-count { margin-left: auto; align-self: center; }
  .card__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card__actions .btn { min-height: 46px; }
  .addform { grid-template-columns: 1fr; padding: 10px; }
  .addform__input:first-child { grid-column: auto; }
  .table { min-width: 530px; }
  .dialog__actions, .prompt-pop__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dialog__actions .btn, .prompt-pop__actions .btn { width: 100%; }
}

@media (max-width: 359px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls { margin-left: 41px; max-width: none; }
  .view__tools { grid-template-columns: 1fr; }
  .view__tools .btn:first-child { grid-column: auto; }
  .caption-label__tools .btn { flex: 1 1 100%; }
  .card__actions { grid-template-columns: 1fr; }
}
.card__badges { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
@media (max-width: 440px) {
  .card__head { align-items: flex-start; }
  .card__meta { min-width: 0; flex: 1 1 auto; }
  .card__badges { flex: 0 0 auto; max-width: 42%; }
}

@media (max-width: 440px) {
  .topbar__controls { flex: 1 1 0; width: auto; max-width: none; }
}

/* ---------- UI audit refinements v13 ---------- */
html { min-height: 100%; }
body { min-height: 100%; }
#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Combined filter state: JS keeps btn--ghost while toggling btn--accent. */
.btn.btn--ghost.btn--accent {
  background: var(--accent);
  border-color: transparent;
  color: #06120c;
}
.btn.btn--ghost.btn--accent:hover:not(:disabled) { background: var(--accent-press); }

.chip, .title-input { font-family: inherit; line-height: 1.2; }
.badge--type {
  color: #9db7c6;
  background: rgba(143, 168, 184, .12);
  border-color: rgba(143, 168, 184, .35);
}

.card__head { align-items: flex-start; }
.card__badges { gap: 6px; }
.card__actions .btn--span2 { grid-column: auto; }
.card__actions [data-act="republish"] { grid-column: 1 / -1; }
.card__actions [data-act="archive-delete"] { grid-column: 1 / -1; }
.card > .card__schedule { margin: 9px 0 0; grid-column: auto; }
.card__actions > .card__schedule { grid-column: 1 / -1; margin: 0; }

.author-input,
.field__input,
.devbar__input,
.addform__input,
.addform__select,
.src-controls input[type="text"],
.src-controls select {
  min-height: var(--control-h);
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--text);
  font-family: inherit;
}
.src-controls select { width: 100%; min-width: 110px; padding: 7px; }
:where(.author-input, .title-input, .field__input, .devbar__input, .addform__input, .addform__select, .src-controls input[type="text"], .src-controls select, .prompt-pop__input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.src-actions .btn { min-height: 36px; }
.chip--btn { min-height: 34px; font-size: 11px; }
.dialog__close { width: 40px; height: 40px; padding: 0; }
.lightbox__close { width: 40px; height: 40px; }
.photo-item__select { width: 40px; height: 40px; top: 0; left: 0; }
.photo-item__check { inset: 6px auto auto 6px; width: 22px; height: 22px; }

.dialog, .prompt-pop__box, .llm-dropdown { border-radius: var(--radius); }
.card__video video, .prompt-pop__input { border-radius: var(--radius-sm); }
.llm-dropdown, .prompt-pop__box { background: var(--bg-elev); border-color: var(--line); }
.prompt-pop {
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(4, 10, 16, .72);
}
.prompt-pop__box, .dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
.prompt-pop__head, .dialog__title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.prompt-pop__input { background: var(--card-2); color: var(--text); border-color: var(--line); }
.llm-dropdown__body p, .llm-row__text small, .prompt-pop__hint { color: var(--muted); }
.llm-ok { background: var(--accent); }
.llm-down { background: var(--danger); }

/* Source list becomes readable cards on phones; desktop table is unchanged. */
@media (max-width: 600px) {
  .tablewrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .table { min-width: 0; border-collapse: separate; }
  .table thead { display: none; }
  .table, .table tbody { display: block; width: 100%; }
  .table tbody { display: flex; flex-direction: column; gap: 10px; }
  .table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 12px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .17);
  }
  .table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .table tbody td:first-child,
  .table tbody td.table__actions { grid-column: 1 / -1; }
  .table tbody td:first-child { display: block; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .table tbody td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .35px;
  }
  .table tbody td:nth-child(4), .table tbody td:nth-child(5) { grid-column: 1 / -1; }
  .table tbody td.table__actions { padding-top: 8px; border-top: 1px solid var(--line); }
  .src-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .src-actions .btn { width: 100%; }
  .src-controls { width: 100%; }
  .src-last, .src-error { text-align: right; }
}

@media (min-width: 620px) {
  .card__actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Cross-source duplicate variants v17 ---------- */
body.dialog-open { overflow: hidden; }
.duplicates-link {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid rgba(46, 158, 107, .55);
  border-radius: 999px;
  background: rgba(46, 158, 107, .12);
  color: #78d7a4;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.duplicates-link:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.duplicates-dialog {
  display: flex;
  flex-direction: column;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.duplicates-head { flex: 0 0 auto; }
.duplicates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 8px;
}
.variant-row {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  cursor: pointer;
}
.variant-row.is-representative { border-color: rgba(46, 158, 107, .65); }
.variant-row > input { position: absolute; opacity: 0; }
.variant-radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--card-2);
}
.variant-row > input:checked + .variant-radio { background: var(--accent); border-color: var(--accent); }
.variant-row > input:focus-visible + .variant-radio { outline: 2px solid var(--text); outline-offset: 3px; }
.variant-row > input:disabled + .variant-radio { opacity: .45; }
.variant-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.variant-title { font-weight: 700; overflow-wrap: anywhere; }
.variant-author, .variant-meta { color: var(--muted); font-size: 11px; }
.variant-source { width: fit-content; color: #7fc7e8; font-size: 12px; }
.variant-badge {
  align-self: start;
  padding: 3px 7px;
  border-radius: 999px;
  color: #78d7a4;
  background: rgba(46, 158, 107, .14);
  font-size: 10px;
  font-weight: 700;
}
.duplicates-reason {
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px solid rgba(183, 163, 107, .4);
  border-radius: var(--radius-sm);
  background: rgba(183, 163, 107, .1);
  color: #d2c184;
  font-size: 12px;
}
.duplicates-actions { flex: 0 0 auto; padding-top: 10px; border-top: 1px solid var(--line); }

@media (max-width: 479px) {
  .overlay--sheet { padding: 0; }
  .duplicates-dialog {
    max-width: none;
    max-height: min(88dvh, 760px);
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding: 14px 12px max(14px, env(safe-area-inset-bottom, 0px));
  }
  .variant-row { min-height: 76px; grid-template-columns: 24px minmax(0, 1fr); }
  .variant-badge { grid-column: 2; justify-self: start; }
  .duplicates-actions { display: grid; grid-template-columns: 1fr 1.25fr; }
  .duplicates-actions .btn { min-height: 48px; }
}

@media (max-width: 440px) {
  .caption-wrap > .caption-label { align-items: flex-start; flex-direction: column; }
  .title-wrap > .caption-label { align-items: center; flex-direction: row; }
  .view__tools > .btn--accent { grid-column: 1 / -1; }
  .view__tools .btn:first-child:not(.btn--accent) { grid-column: auto; }
  .card__actions .btn { min-height: 44px; }
  .card__badges { max-width: 45%; }
}

@media (max-width: 379px) {
  .topbar { flex-wrap: wrap; }
  .topbar__controls {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
    align-items: stretch;
  }
  .chips { justify-content: flex-end; }
}

/* Compact source rows and platform filter pills. */
.source-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 10px;
}
.source-filter {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .035);
  color: var(--muted);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.source-filter:hover {
  border-color: rgba(46, 158, 107, .5);
  color: var(--text);
}
.source-filter.is-active {
  border-color: rgba(46, 158, 107, .72);
  background: rgba(46, 158, 107, .16);
  color: #dff8ec;
}
.source-filter span {
  margin-left: 4px;
  color: inherit;
  opacity: .7;
}
#sources-table th,
#sources-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}
#sources-table .src-title {
  margin-bottom: 1px;
  line-height: 1.15;
}
#sources-table .src-url,
#sources-table .src-last {
  line-height: 1.2;
}
#sources-table .btn--sm {
  min-height: 28px;
  padding: 5px 8px;
}

@media (max-width: 600px) {
  .source-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: -2px;
    padding: 2px;
  }
  .source-filters::-webkit-scrollbar { display: none; }
  .source-filter { flex: 0 0 auto; }
  #sources-table tbody tr {
    padding: 9px 10px;
    gap: 5px 10px;
  }
  #sources-table tbody td {
    min-height: 24px;
    padding: 3px 0;
  }
}

/* Extra-compact mobile source cards: keep information, remove empty height. */
@media (max-width: 600px) {
  #sources-table tbody {
    gap: 7px;
  }
  #sources-table tbody tr {
    row-gap: 2px;
    column-gap: 8px;
    padding: 7px 9px;
    border-radius: 14px;
  }
  #sources-table tbody td {
    min-height: 20px;
    padding: 1px 0;
    gap: 6px;
  }
  #sources-table tbody td:first-child {
    padding-bottom: 4px;
  }
  #sources-table .src-title {
    font-size: 13px;
    line-height: 1.15;
  }
  #sources-table .src-url {
    margin-top: 0;
    font-size: 11px;
    line-height: 1.15;
  }
  #sources-table tbody td[data-label]::before {
    font-size: 9px;
    line-height: 1;
  }
  #sources-table tbody td:nth-child(4) {
    min-height: 22px;
  }
  #sources-table tbody td.source-error-empty {
    display: none;
  }
  #sources-table tbody td.table__actions {
    padding-top: 5px;
    margin-top: 2px;
  }
  #sources-table .src-actions {
    gap: 6px;
  }
  #sources-table .src-actions .btn {
    min-height: 30px;
    padding: 5px 8px;
  }
}

/* ---------- Ручные хештеги ---------- */
.hashtag-wrap { margin-top: 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.hashtag-toggle { width: 100%; border: 0; background: var(--card-2); color: var(--text); padding: 11px 12px; display: flex; justify-content: space-between; align-items: center; font: inherit; cursor: pointer; }
.hashtag-summary { color: var(--muted); font-size: 12px; }
.hashtag-panel { padding: 10px 11px 12px; background: rgba(8, 24, 36, .45); border-top: 1px solid var(--line); }
.hashtag-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.hashtag-chip { cursor: pointer; }
.hashtag-chip.chip--off { opacity: .48; text-decoration: line-through; border-color: rgba(230, 88, 88, .45); color: #d88989; background: rgba(120, 20, 20, .12); }
.hashtag-help { margin-top: 9px; color: var(--muted); font-size: 11px; line-height: 1.4; }

/* ---------- Растягиваемый редактор ---------- */
.caption-editor { position: relative; }
.caption-editor .caption { display: block; padding-right: 40px; padding-bottom: 32px; resize: vertical; }
.caption-resize { position: absolute; right: 3px; bottom: 3px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 23px; line-height: 1; cursor: ns-resize; touch-action: none; user-select: none; }
.caption-resize:active { color: var(--accent); }

/* ---------- Канал публикации и верхнее удаление ---------- */
.card__head-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 7px; flex: 0 0 auto; }
.card__top-reject { min-width: 0; padding: 5px 9px; line-height: 1.15; }
.badge--channel { color: #9fd4e9; background: rgba(127, 199, 232, .08); border-color: rgba(127, 199, 232, .38); }
.badge--channel-unknown { color: var(--muted); border-style: dashed; background: transparent; }
@media (max-width: 520px) {
  .card__head-actions { flex-direction: column-reverse; align-items: flex-end; gap: 5px; max-width: 46%; }
  .card__top-reject { font-size: 11px; }
}


/* ---------- Фильтр отчётов по источникам ---------- */
.report-source-filter { margin: 8px 0 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 24, 36, .35); }
.report-source-filter > summary { cursor: pointer; padding: 10px 12px; color: var(--text); font-size: 13px; font-weight: 700; list-style-position: inside; }
.report-source-filter__panel { padding: 0 10px 11px; border-top: 1px solid var(--line); }
.report-source-filter__actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 9px 0; }
.report-source-options { display: flex; flex-wrap: wrap; gap: 7px; }
.report-source-option { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--card); cursor: pointer; font-size: 12px; }
.report-source-option.is-on { color: #a8e0c0; border-color: rgba(46, 158, 107, .6); background: rgba(46, 158, 107, .12); }
.report-source-option input { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.report-source-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-source-option small { color: var(--muted); font-size: 10px; }
@media (max-width: 520px) {
  .report-source-options { flex-direction: column; }
  .report-source-option { width: 100%; border-radius: 9px; min-height: 38px; }
}
.reports-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 9px; }
#reports-empty > span { display: block; }
.report-source-option small { margin-left: auto; white-space: nowrap; }

/* ---------- Быстрая навигация по длинной ленте ---------- */
:root {
  --scroll-toast-clearance: 0px;
  --tg-content-safe-bottom: 0px;
}
.scroll-nav {
  position: fixed;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: calc(max(12px, env(safe-area-inset-bottom, 0px), var(--tg-content-safe-bottom)) + var(--scroll-toast-clearance));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 20px);
}
.scroll-nav__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 1px solid rgba(127, 199, 232, .55);
  border-radius: 50%;
  background: rgba(11, 28, 42, .92);
  color: #bfe8f7;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .42);
  backdrop-filter: blur(8px);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.scroll-nav__button--return { border-color: rgba(46, 158, 107, .75); color: #a8e0c0; }
.scroll-nav__button:hover { background: rgba(20, 48, 66, .96); }
.scroll-nav__button:focus-visible { outline: 3px solid rgba(127, 199, 232, .9); outline-offset: 3px; }
.scroll-nav__button:disabled { opacity: .45; cursor: default; }
body.dialog-open .scroll-nav { display: none; }
.card.is-scroll-return-target,
#sources-body tr.is-scroll-return-target { outline: 2px solid var(--accent); outline-offset: 3px; animation: scroll-return-pulse .8s ease-out 2; }
@keyframes scroll-return-pulse { 50% { outline-color: #9fd4e9; } }
@media (max-width: 480px) {
  .scroll-nav { gap: 7px; }
  .scroll-nav__button { width: 42px; height: 42px; min-width: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .card.is-scroll-return-target,
  #sources-body tr.is-scroll-return-target { animation: none; }
}
.scanresults__item.is-warning { border-color: rgba(224, 169, 73, .58); }
.scan-history { color: #9fd4e9; font-size: 12px; }
.scan-warning { color: #e3b96d; font-size: 12px; overflow-wrap: anywhere; }
.src-last.warn { color: #e3b96d; }


/* ---------- LLM provider picker (v27) ---------- */
.llm-dropdown__head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.llm-provider-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.llm-provider-row .chip {
  min-height: 30px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
}
.llm-provider-row .chip:disabled { opacity: .55; cursor: default; }
.llm-provider-note { margin: -2px 0 8px; font-size: 11px; color: #9fb3c8; line-height: 1.35; }
.llm-dropdown__body { max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Компактная шапка карточки (v27) ---------- */
@media (max-width: 720px) {
  .card__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 4px 8px;
  }
  .card__meta { grid-column: 1 / -1; }
  .card__head-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 5px;
    max-width: none;
  }
  .card__badges { justify-content: flex-start; }
  .card__top-reject { order: 3; margin-left: auto; font-size: 11px; padding: 4px 10px; }
}


/* ---------- Занятые слоты в диалоге планирования (v27) ---------- */
.schedule-busy { margin-top: 8px; }
.schedule-busy[hidden] { display: none; }
.schedule-busy .field__label { display: block; margin-bottom: 5px; }
.schedule-busy__list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 96px; overflow-y: auto; }
.schedule-busy__item {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid rgba(224, 169, 73, .4);
  border-radius: 999px;
  background: rgba(224, 169, 73, .08);
  color: #e3b96d;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.schedule-busy__item.is-postponed { border-style: dashed; }


/* ---------- Редактор постов (composer, v29) ---------- */
.overlay--full {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 18, 0.72);
  display: flex;
  align-items: stretch;
  justify-content: center;
  z-index: 95;
  padding: 0;
}
.overlay--full[hidden] { display: none; }
.compose-editor {
  width: min(680px, 100%);
  background: #0d1826;
  overflow-y: auto;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
}
.compose-editor__head { display: flex; align-items: center; justify-content: space-between; }
.compose-editor__title { margin: 0; font-size: 16px; }
.compose-editor__title-input {
  width: 100%;
  box-sizing: border-box;
  background: #0b1420;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: inherit;
  padding: 9px 12px;
  font: inherit;
  font-weight: 700;
}
/* Тулбар без sticky и без переноса строк: sticky-панель визуально
   НАКРЫВАЕТ первую строку текста, когда клавиатура проскролливает
   контейнер к каретке (жалоба 2026-08-30). Теперь панель просто
   скроллится вместе с редактором, а лишние кнопки уходят в
   горизонтальный скролл, а не на вторую строку. */
.compose-editor__toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.compose-editor__toolbar::-webkit-scrollbar { display: none; }
.tool-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #12212f;
  color: inherit;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.tool-btn:active { background: #1b3040; }
.tool-sep { display: none; }
.compose-editor__fieldwrap { position: relative; }
.compose-editor__fieldwrap .caption-resize { z-index: 2; }
.compose-editor__field {
  /* Поле само растёт с текстом, но НЕ выше свободного места: при
     длинном тексте включается внутренний скролл, иначе набранное
     сверху нельзя посмотреть (жалоба 2026-08-30). Свободная высота
     считается в JS: min-height 220px, максимум - до низа экрана. */
  min-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #0b1420;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.compose-editor__field:focus { outline: 1px solid rgba(46, 158, 107, 0.55); }
.compose-editor__field.is-empty:before {
  content: attr(data-placeholder);
  color: #6d8194;
  pointer-events: none;
}
.compose-editor__field h2 { font-size: 18px; margin: 0.6em 0 0.3em; }
.compose-editor__field a { color: #7cc7ff; }
.compose-editor__media-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compose-editor__media-hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.compose-media-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 2px;
}
.compose-media {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  overflow: hidden;
  background: #0b1420;
}
.compose-media__thumb { display: block; width: 96px; height: 96px; object-fit: cover; }
.compose-media__move {
  position: absolute;
  top: 4px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: rgba(4, 10, 18, 0.72);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.compose-media__move[data-move="-1"] { left: 4px; }
.compose-media__move[data-move="1"] { right: 4px; }
.compose-media__move:disabled { opacity: 0.35; }
.compose-media__remove {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 7px;
  background: rgba(160, 40, 40, 0.85);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}
.compose-media__num {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 10px;
  color: #cfe3d8;
  background: rgba(4, 10, 18, 0.6);
  border-radius: 6px;
  padding: 1px 5px;
}
.compose-editor__gen { display: flex; gap: 8px; flex-wrap: wrap; }
.compose-editor__schedule { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.compose-editor__schedule-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.compose-editor__schedule-row { display: flex; gap: 8px; flex-wrap: wrap; }
.compose-editor__schedule-row .field__input { flex: 1 1 150px; }
.compose-editor__actions { display: flex; gap: 8px; align-items: center; }
.compose-editor__spacer { flex: 1; }
.compose-upcoming { margin: 4px 0 10px; }
.compose-upcoming__title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.compose-upcoming__list { display: flex; flex-direction: column; gap: 5px; }
.compose-upcoming__item {
  display: inline-flex;
  padding: 6px 10px;
  border: 1px solid rgba(224, 169, 73, 0.4);
  border-radius: 9px;
  background: rgba(224, 169, 73, 0.08);
  color: #e3b96d;
  font-size: 12px;
  font-weight: 600;
}
.compose-card { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.compose-card__title { font-weight: 700; margin-bottom: 3px; }
.compose-card__preview { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.compose-card__meta { font-size: 11px; color: var(--muted); }
.compose-card__actions { display: flex; gap: 6px; flex: 0 0 auto; }
@media (max-width: 520px) {
  .compose-card { flex-direction: column; align-items: stretch; }
  .compose-card__actions { justify-content: flex-end; }
}

/* Диалог выбора канала для «Опубликовать сейчас».
   z-index выше compose-overlay (95): диалог вызывается ИЗ редактора. */
.overlay.channel-overlay { z-index: 110; }
.channel-dialog { max-width: 340px; width: calc(100% - 32px); }
.channel-dialog__options { display: grid; gap: 10px; padding: 14px 0 4px; }
.channel-option {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2); color: var(--text); font: inherit; cursor: pointer;
}
.channel-option:active { background: rgba(46, 125, 50, 0.18); }
.channel-option__name { font-weight: 600; font-size: 15px; }
.channel-option__hint { font-size: 12px; color: var(--muted, #8aa0b2); }

/* --- Страница «Сервер»: статистика и очистка ------------------------------ */
.server-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .server-stats { grid-template-columns: 1fr; } }
.stat-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card__bar { height: 8px; border-radius: 4px; background: rgba(127, 152, 170, .18); overflow: hidden; }
.stat-card__fill { height: 100%; width: 0; background: var(--accent, #2e9e6b); border-radius: 4px; transition: width .4s ease; }
.stat-card__fill.is-hot { background: #d9534f; }
.stat-card__line { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.stat-card__line b { color: var(--text); font-weight: 600; }
.stat-card__line--col { flex-direction: column; gap: 4px; }
.view__subtitle { font-size: 15px; font-weight: 600; margin: 18px 0 4px; }
.cleanup-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
@media (max-width: 560px) { .cleanup-grid { grid-template-columns: 1fr; } }
.cleanup-item { border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.cleanup-item__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.cleanup-item__head span { font-size: 12px; color: var(--muted); }
.cleanup-item__select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; padding: 3px 6px;
}
.cleanup-item__hint { font-size: 11px; color: var(--muted); margin: 0; }
.cleanup-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.cleanup-auto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.badge--max { background: rgba(46, 158, 107, .16); color: #6fd0a0; border: 1px solid rgba(46, 158, 107, .35); }
.badge--origin { background: rgba(90, 140, 255, .14); color: #9db9ff; border: 1px solid rgba(90, 140, 255, .32); }


/* --- Модерирование: обращения подписчиков --------------------------------- */
.feedback-filter { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.feedback-unread { font-size: 12px; color: #6fd0a0; background: rgba(46, 158, 107, .14); border: 1px solid rgba(46, 158, 107, .3); border-radius: 999px; padding: 2px 10px; }
.feedback-list { display: grid; gap: 10px; margin-top: 6px; }
.feedback-card { border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); padding: 10px 12px; display: grid; gap: 6px; }
.feedback-card--resolved { opacity: .65; }
.feedback-card__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.feedback-card__kind { font-weight: 600; border-radius: 999px; padding: 2px 10px; border: 1px solid transparent; }
.feedback-card__kind--proposal { color: #6fd0a0; background: rgba(46, 158, 107, .14); border-color: rgba(46, 158, 107, .32); }
.feedback-card__kind--complaint { color: #e79390; background: rgba(217, 83, 79, .12); border-color: rgba(217, 83, 79, .35); }
.feedback-card__kind--wish { color: #9db9ff; background: rgba(90, 140, 255, .13); border-color: rgba(90, 140, 255, .3); }
.feedback-card__author { color: var(--text); font-weight: 500; }
.feedback-card__date { margin-left: auto; }
.feedback-card__text { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.feedback-card__resolved { margin: 0; font-size: 12px; color: var(--muted); }
.feedback-card__actions { display: flex; justify-content: flex-end; }

/* --- Tabs: финальное переопределение - одна строка, горизонтальный скролл --- */
.tabs {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tabs__btn {
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
  padding-left: 14px !important;
  padding-right: 14px !important;
}

/* --- Ответ на обращение (Модерирование) ----------------------------------- */
.feedback-card__author--link { color: #7fb5ff; text-decoration: underline; text-underline-offset: 2px; }
.feedback-card__reply { display: grid; gap: 8px; margin-top: 4px; }
.feedback-card__reply-text {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: var(--bg-elev, #0f1e2b); color: var(--text, #e8eef2);
  border: 1px solid var(--line, #2a3a4a); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 14px;
}
.feedback-card__actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.feedback-card__actions .feedback-card__resolved { margin: 0; margin-right: auto; }

/* --- Баны в Модерировании -------------------------------------------------- */
.feedback-bans { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 6px 0 10px; }
.feedback-bans__item { display: inline-flex; align-items: center; gap: 6px; background: rgba(217, 83, 79, .1); border: 1px solid rgba(217, 83, 79, .3); color: #e79390; border-radius: 999px; padding: 2px 10px; }
.feedback-bans__unban { border: 0; background: transparent; color: #7fb5ff; cursor: pointer; font: inherit; font-size: 12px; text-decoration: underline; padding: 0; }
.btn--danger { color: #e79390; border-color: rgba(217, 83, 79, .4); background: rgba(217, 83, 79, .08); }
.btn--danger:hover { background: rgba(217, 83, 79, .16); }

/* ---------- Плавное удаление карточки (optimistic UI) ---------- */

.card.is-removing {
  overflow: hidden;
  opacity: 0;
  transform: scale(.98);
  transition: opacity .22s ease, transform .22s ease,
    margin .26s ease, padding .26s ease, max-height .26s ease;
  max-height: 0 !important;
  margin: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-width: 0;
  pointer-events: none;
}

.card.is-leaving {
  opacity: .35;
  pointer-events: none;
  transition: opacity .15s ease;
}
