/* LPPNews — панель редактора. Монохромная тема. */
:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #181818;
  --surface-3: #202020;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #f5f5f5;
  --text-2: #b4b4b4;
  --muted: #7a7a7a;
  --white: #ffffff;
  --danger: #e5484d;
  --radius: 0.5rem;
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

/* Размер всего интерфейса задаёт 1rem: на 1440px это 16px, на 1920px ~19px, на 2560px 22px.
   --ui-scale — ручная поправка из боковой панели (Масштаб). */
html { font-size: calc(clamp(13px, 6px + 0.7vw, 22px) * var(--ui-scale, 1)); }
@media (max-width: 860px) { html { font-size: calc(15px * var(--ui-scale, 1)); } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 0.875rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.3; }
h2 { font-size: 0.9375rem; font-weight: 600; margin: 0; }
code { font-family: var(--mono); font-size: 0.75rem; background: var(--surface-3); padding: 1px 0.3125rem; border-radius: 0.25rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.icon { width: 1rem; height: 1rem; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: 14.5rem 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); padding: 1.25rem 0.75rem;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.logo { display: flex; align-items: center; gap: 0.625rem; padding: 0 0.5rem 1.5rem; font-weight: 700; font-size: 0.9375rem; letter-spacing: .02em; }
.logo-mark { width: 1.625rem; height: 1.625rem; border-radius: 0.375rem; background: var(--white); color: #000; display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; }
.section-label { font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 0 0.5rem 0.5rem; }
.channel {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; border-radius: 0.375rem;
  color: var(--text-2); font-weight: 500;
}
.channel:hover { background: var(--surface-2); color: var(--text); }
.channel.active { background: var(--surface-3); color: var(--text); }
.channel-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--text-2); }
.channel.active .count { color: var(--text); }
.sidebar-foot { margin-top: auto; padding: 0 0.5rem; font-size: 0.75rem; color: var(--muted); line-height: 1.6; }
.main { padding: 1.75rem 2.25rem 3rem; min-width: 0; max-width: 105rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; }
.page-sub { color: var(--muted); margin-top: 0.25rem; }
.breadcrumbs { display: flex; gap: 0.375rem; color: var(--muted); font-size: 0.8125rem; margin-bottom: 0.375rem; }
.breadcrumbs a:hover { color: var(--text); }

/* ---------- кнопки и контролы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.25rem; padding: 0 0.875rem; border-radius: 0.375rem; font: 500 0.875rem var(--font); cursor: pointer;
  border: 1px solid var(--border-strong); background: transparent; color: var(--text); white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #4a4a4a; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--white); border-color: var(--white); color: #000; }
.btn-primary:hover { background: #dcdcdc; border-color: #dcdcdc; }
.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-sm { height: 1.875rem; padding: 0 0.625rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.spinner {
  width: 0.875rem; height: 0.875rem; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab { padding: 0.625rem 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-color: var(--white); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 0.375rem; padding: 2px; gap: 2px; background: var(--surface); }
.segmented > * {
  border: none; background: transparent; color: var(--muted); height: 1.75rem; padding: 0 0.75rem; border-radius: 0.25rem;
  font: 500 0.8125rem var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem;
}
.segmented > *:hover { color: var(--text); }
.segmented > .active { background: var(--surface-3); color: var(--text); }
.segmented .n { color: var(--muted); font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex; align-items: center; height: 1.25rem; padding: 0 0.4375rem; border-radius: 0.25rem;
  border: 1px solid var(--border-strong); font-size: 0.6875rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-2);
}
.tag-solid { background: var(--white); border-color: var(--white); color: #000; }
.tag-danger { border-color: var(--danger); color: var(--danger); }

label.field, .field { display: block; margin-bottom: 1rem; }
.field-label { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; font-weight: 500; color: var(--text-2); margin-bottom: 0.375rem; }
.field-hint { font-weight: 400; color: var(--muted); }
textarea, input[type="datetime-local"] {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 0.375rem; padding: 0.625rem 0.75rem; font: 0.875rem/1.5 var(--font); resize: vertical;
}
textarea::placeholder { color: #555; }
textarea:focus, input:focus { outline: none; border-color: #6a6a6a; }
input[type="datetime-local"] { height: 2.25rem; padding: 0 0.625rem; color-scheme: dark; }

/* ---------- лента ---------- */
.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 18.75rem; gap: 2rem; align-items: start; }
.filters { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border); background: var(--surface); }
.item:first-child { border-top: none; }
.item:hover { background: var(--surface-2); }
.item-main { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; }
.thumb { width: 8rem; height: 4rem; border-radius: 0.375rem; overflow: hidden; background: var(--surface-3); flex: none; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb img.mod-icon { width: 3rem; height: 3rem; border-radius: 0.5rem; image-rendering: pixelated; }
.thumb-empty { font-size: 0.6875rem; color: var(--muted); }
.item-text { min-width: 0; }
.item-meta { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.75rem; margin-bottom: 0.25rem; }
.item-title { font-size: 0.9375rem; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-sub { display: flex; gap: 0.75rem; color: var(--muted); font-size: 0.75rem; margin-top: 0.25rem; }
.item-actions { display: flex; gap: 0.375rem; flex: none; opacity: .55; transition: opacity .12s; }
.item:hover .item-actions { opacity: 1; }
.empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

.aside-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); position: sticky; top: 1.75rem; }
.aside-card h2 { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); }
.queue-item { display: block; padding: 0.75rem 1rem; border-top: 1px solid var(--border); }
.queue-item:first-of-type { border-top: none; }
.queue-item:hover { background: var(--surface-2); }
.queue-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); margin-bottom: 2px; }
.queue-time { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.queue-title { font-size: 0.8125rem; color: var(--text-2); line-height: 1.4; }
.aside-empty { padding: 1rem; color: var(--muted); font-size: 0.8125rem; }

/* ---------- редактор ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(16.25rem, .9fr) minmax(26.25rem, 1.35fr) minmax(21.25rem, 1fr); gap: 1.25rem; align-items: start; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--border); }
.step { display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 0.6875rem; font-weight: 600; color: var(--text-2); margin-right: 0.5rem; }
.panel-body { padding: 1.125rem; }
.panel-section + .panel-section { border-top: 1px solid var(--border); }
.sticky { position: sticky; top: 1.75rem; }

.source-image { width: 100%; border-radius: 0.375rem; margin-bottom: 0.875rem; display: block; }
.source-image.mod { width: 4.5rem; height: 4.5rem; image-rendering: pixelated; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.375rem 0.875rem; font-size: 0.8125rem; margin-bottom: 0.875rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-2); }
.links { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.875rem; }
.links a { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--text-2); font-size: 0.8125rem; }
.links a:hover { color: var(--text); text-decoration: underline; }
details summary { cursor: pointer; color: var(--text-2); font-size: 0.8125rem; font-weight: 500; padding: 0.25rem 0; list-style: none; display: flex; align-items: center; gap: 0.375rem; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 0.375rem; height: 0.375rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .12s; }
details[open] summary::before { transform: rotate(45deg); }
.source-text {
  white-space: pre-wrap; font: 0.8125rem/1.6 var(--font); color: var(--text-2);
  max-height: 62vh; overflow: auto; padding: 0.75rem; border-radius: 0.375rem; background: var(--bg);
  border: 1px solid var(--border); margin: 0.5rem 0 0;
}

.generate-row { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.model { font-size: 0.75rem; color: var(--muted); font-family: var(--mono); }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 0.25rem; border: 1px solid var(--border); border-bottom: none; border-radius: 0.375rem 0.375rem 0 0; background: var(--surface-2); }
.toolbar button {
  height: 1.75rem; min-width: 1.875rem; padding: 0 0.5rem; border: none; border-radius: 0.25rem; background: transparent;
  color: var(--text-2); font: 500 0.8125rem var(--font); cursor: pointer;
}
.toolbar button:hover { background: var(--surface-3); color: var(--text); }
.toolbar .sep { width: 1px; background: var(--border-strong); margin: 0.25rem 0.25rem; }
.post-text { min-height: 28.75rem; border-radius: 0 0 0.375rem 0.375rem; font: 0.8438rem/1.6 var(--mono); }
.counter-line { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
.over { color: var(--danger); font-weight: 600; }
.status { display: flex; align-items: center; gap: 0.5rem; }
.publish-block { display: flex; flex-direction: column; gap: 0.625rem; }
.schedule-row { display: flex; gap: 0.5rem; }
.schedule-row input { flex: 1; min-width: 0; }
.error-text { color: var(--danger); font-size: 0.8125rem; }

/* ---------- предпросмотр Telegram ---------- */
.tg { background: #0b0b0b; border: 1px solid var(--border); border-radius: 0.375rem; padding: 0.875rem; max-height: 58vh; overflow: auto; }
.tg-bubble { background: #1b1b1b; border-radius: 0.625rem; overflow: hidden; }
.tg-image { display: block; width: 100%; }
.tg-text { padding: 0.5rem 0.75rem 0.25rem; white-space: pre-wrap; word-wrap: break-word; font-size: 0.875rem; line-height: 1.45; color: #ececec; }
.tg-text a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.tg-text code { background: #2a2a2a; color: #ddd; }
.tg-text blockquote { margin: 0.25rem 0; padding: 0.25rem 0.625rem; border-left: 2px solid #8a8a8a; background: #232323; border-radius: 0 0.25rem 0.25rem 0; position: relative; }
.tg-text blockquote[expandable] { cursor: pointer; padding-right: 1.375rem; }
.tg-text blockquote[expandable].collapsed { max-height: 4.4em; overflow: hidden; }
.tg-text blockquote[expandable]::after {
  content: ""; position: absolute; right: 0.5rem; bottom: 0.5rem; width: 0.375rem; height: 0.375rem;
  border-right: 1.5px solid #aaa; border-bottom: 1.5px solid #aaa; transform: rotate(-135deg);
}
.tg-text blockquote[expandable].collapsed::after { transform: rotate(45deg); bottom: 0.625rem; }
.tg-text tg-spoiler { background: #4a4a4a; color: transparent; border-radius: 0.1875rem; cursor: pointer; }
.tg-text tg-spoiler.shown { background: none; color: inherit; }
.tg-meta { text-align: right; font-size: 0.6875rem; color: #6f6f6f; padding: 0 0.625rem 0.375rem; }
.tg-empty { padding: 1.75rem 0.75rem; text-align: center; color: var(--muted); font-size: 0.8125rem; }

/* ---------- уведомления ---------- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; max-width: 26.25rem;
  background: var(--white); color: #000; padding: 0.75rem 1rem; border-radius: 0.375rem; font-weight: 500;
  opacity: 0; transform: translateY(0.5rem); pointer-events: none; transition: all .18s; white-space: pre-line; z-index: 10;
  box-shadow: 0 0.5rem 1.875rem rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 1400px) {
  .editor-layout { grid-template-columns: 1fr 1fr; }
  .source-panel { grid-column: 1 / -1; order: 3; }
  .sticky { position: static; }
  .source-image:not(.mod) { max-width: 26.25rem; }
}
@media (max-width: 1000px) {
  .feed-layout { grid-template-columns: 1fr; }
  .aside-card { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-foot { display: none; }
  .editor-layout { grid-template-columns: 1fr; }
  .main { padding: 1.25rem 1rem; }
  .thumb { width: 5.5rem; height: 3rem; }
  .item-actions { display: none; }
}

/* ---------- статус сервисов ---------- */
.service-widget { display: block; border: 1px solid var(--border); border-radius: 0.375rem; padding: 0.5rem 0.625rem; margin: 0 0 1rem; }
.service-widget:hover { border-color: var(--border-strong); }
.service { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-2); padding: 0.1875rem 0; }
.service-state { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #444; flex: none; }
.dot-ok { background: var(--white); }
.dot-bad { background: var(--danger); }
.sidebar-nav { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.status-row { display: flex; gap: 0.625rem; align-items: flex-start; padding: 0.5rem 0; border-top: 1px solid var(--border); white-space: pre; }
.status-row:first-child { border-top: none; }
.status-row .dot { margin-top: 0.375rem; }
.status-row .small { white-space: normal; }
.status-title { font-weight: 500; }

/* ---------- настройки ---------- */
.small { font-size: 0.75rem; }
.mono { font-family: var(--mono); font-size: 0.8125rem; }
input[type="text"], input[type="number"], input[type="password"], input:not([type]) {
  width: 100%; height: 2.25rem; padding: 0 0.625rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 0.375rem; font: 0.875rem var(--font);
}
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.narrow { max-width: 40rem; }
.row-gap { display: flex; gap: 0.5rem; }
.input-row { display: flex; align-items: center; gap: 0.75rem; }
.check { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
.form-hint { margin-bottom: 1rem; }
p.small { margin: 0 0 0.875rem; }
#model-availability { margin: -6px 0 1rem; }
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }

/* ---------- выбор медиа из источника ---------- */
.segmented.wrap { flex-wrap: wrap; }
.media-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: 0.5rem; margin-top: 0.625rem; }
.media-tile {
  aspect-ratio: 16 / 10; padding: 0; border: 1px solid var(--border); border-radius: 0.375rem; overflow: hidden;
  background: var(--surface-3); cursor: pointer; color: var(--text-2);
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile:hover { border-color: var(--border-strong); }
.media-tile.active { border: 2px solid var(--white); }
.media-video { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.75rem; }
.media-video .icon { width: 1.375rem; height: 1.375rem; fill: currentColor; }
.media-upload { border-style: dashed; display: block; }
.media-upload:hover { color: var(--text); }
video.tg-image { background: #000; max-height: 26.25rem; }
.segmented > * { white-space: nowrap; }
.media-tile { min-width: 0; max-height: 7.5rem; }
.panel { overflow: hidden; }
.tg-image { max-width: 100%; }

/* ---------- оформление канала ---------- */
.brand-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem 0.875rem; margin-top: 0.75rem;
  padding: 0.625rem 0.75rem; border: 1px solid var(--border); border-radius: 0.375rem; background: var(--surface-2); }
.check-strong { color: var(--text); font-weight: 500; }
.check input { accent-color: var(--white); width: 0.9375rem; height: 0.9375rem; margin: 0; }
/* схема кадра: 4 угла, выбранный подсвечен */
.corner-picker { position: relative; width: 3.25rem; height: 2rem; border: 1px solid var(--border-strong); border-radius: 0.25rem; }
.corner { position: absolute; width: 1rem; height: 0.5625rem; padding: 0; border: 1px solid var(--border-strong);
  border-radius: 2px; background: transparent; cursor: pointer; }
.corner:hover { border-color: var(--text-2); }
.corner.active { background: var(--white); border-color: var(--white); }
.corner-tl { top: 0.1875rem; left: 0.1875rem; }
.corner-tr { top: 0.1875rem; right: 0.1875rem; }
.corner-bl { bottom: 0.1875rem; left: 0.1875rem; }
.corner-br { bottom: 0.1875rem; right: 0.1875rem; }

/* ---------- второй уровень фильтров, поиск, сортировка ---------- */
.subfilters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; margin-bottom: 0.75rem; }
.subfilters-label { font-size: 0.75rem; color: var(--muted); margin-right: 0.25rem; text-transform: uppercase; letter-spacing: .06em; }
.chip { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.75rem; padding: 0 0.625rem; border-radius: 0.375rem;
  border: 1px solid var(--border); background: var(--surface); font-size: 0.8125rem; color: var(--text-2); white-space: nowrap; }
.chip span { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--white); border-color: var(--white); color: #000; }
.chip.active span { color: #444; }
.toolbar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.875rem; }
.toolbar-row input[type="search"] { flex: 1; min-width: 0; height: 2.125rem; padding: 0 0.625rem; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); border-radius: 0.375rem; font: 0.875rem var(--font); }
.toolbar-row select { height: 2.125rem; padding: 0 0.5rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 0.375rem; font: 0.875rem var(--font); color-scheme: dark; }
.toolbar-row input:focus, .toolbar-row select:focus { outline: none; border-color: #6a6a6a; }

/* ---------- каркас: подвал боковой панели, мобильное меню ---------- */
.section-gap { margin-top: 1.5rem; }
.sidebar-foot { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.75rem; }
.scale-control { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; color: var(--muted); }
.scale-control select { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); border-radius: 0.3rem;
  height: 1.75rem; padding: 0 0.4rem; font: 0.75rem var(--font); color-scheme: dark; }
.link-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0; border: none; background: none;
  color: var(--muted); font: 0.75rem var(--font); cursor: pointer; }
.link-btn:hover { color: var(--text); }
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .mobile-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
  .mobile-bar .logo { padding: 0; }
  .sidebar { display: none; }
  body.menu-open .sidebar { display: flex; }
  .sidebar > .logo { display: none; }
}

/* ---------- окно горячих клавиш ---------- */
.dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 1.5rem; max-width: 32rem; width: calc(100% - 2rem); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 { margin-bottom: 1rem; }
.dialog form { margin-top: 1.25rem; text-align: right; }
.keys { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.keys th { text-align: left; color: var(--muted); font-weight: 600; padding: 0.75rem 0 0.25rem; font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: .06em; }
.keys td { padding: 0.3rem 0; border-top: 1px solid var(--border); color: var(--text-2); }
.keys td:first-child { white-space: nowrap; padding-right: 1rem; color: var(--text); }
kbd { display: inline-block; min-width: 1.4rem; padding: 0.05rem 0.35rem; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 0.25rem; font: 0.75rem var(--mono); text-align: center; background: var(--surface-2); }

/* ---------- лента: сводка, галочки, массовые действия, выделение с клавиатуры ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.stat-card { flex: 1 1 8rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem;
  background: var(--surface); }
.stat-card b { display: block; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-card span { font-size: 0.75rem; color: var(--muted); }
.item.focused { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--white); }
.item.selected { background: var(--surface-2); }
.bulk-bar { position: sticky; bottom: 1rem; z-index: 4; display: flex; align-items: center; gap: 0.75rem;
  margin-top: 1rem; padding: 0.625rem 1rem; border-radius: var(--radius); background: var(--white); color: #000;
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, .5); }
.bulk-bar .btn { color: #000; border-color: #bbb; }
.bulk-bar .btn:hover { background: #eee; }
.bulk-bar .spacer { flex: 1; }
.list-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); font-size: 0.75rem; color: var(--muted); }
.hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.75rem; }

/* ---------- редактор: навигация между новостями, быстрое время ---------- */
.nav-row { display: flex; align-items: center; gap: 0.5rem; }
.nav-pos { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: center; }
.presets { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.presets .btn { height: 1.75rem; padding: 0 0.6rem; font-size: 0.75rem; }

/* ---------- настройки Gemini ---------- */
.model-list { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 0.75rem; }
.model-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.625rem; border: 1px solid var(--border);
  border-radius: 0.375rem; background: var(--bg); }
.model-row .rank { width: 4.75rem; flex: none; font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.model-row .rank-primary { color: var(--text); font-weight: 600; }
.model-row .name { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; }
.model-row .result { font-size: 0.75rem; color: var(--muted); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-row .result.ok { color: var(--text); }
.model-row .result.bad { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 1px solid var(--border);
  border-radius: 0.3rem; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.add-row { display: flex; gap: 0.5rem; }
.add-row select { flex: 1; min-width: 0; height: 2.25rem; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 0.375rem; padding: 0 0.5rem; font: 0.875rem var(--font); color-scheme: dark; }
.range-row { display: flex; align-items: center; gap: 0.75rem; }
.range-row input[type="range"] { flex: 1; accent-color: var(--white); }
.range-row output { min-width: 2.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.range-labels { display: flex; justify-content: space-between; font-size: 0.6875rem; color: var(--muted); margin-top: 0.25rem; }
.explain { font-size: 0.75rem; color: var(--muted); margin: 0.375rem 0 0; line-height: 1.5; }
.toast { display: flex; align-items: center; gap: 1rem; pointer-events: none; }
.toast.show { pointer-events: auto; }
.toast-action { border: none; background: none; padding: 0; font: 600 0.875rem var(--font); color: inherit;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- аккаунты веб-версии Gemini ---------- */
.dropzone { display: flex; flex-direction: column; gap: 0.375rem; align-items: center; text-align: center;
  padding: 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); cursor: pointer;
  background: var(--bg); transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--white); background: var(--surface-2); }
.paste-box { margin: 0.75rem 0; }
.paste-box input { flex: 1; }
.accounts { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.75rem; }
.account-row { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.75rem; border: 1px solid var(--border);
  border-radius: 0.375rem; background: var(--bg); }
.account-main { flex: 1; min-width: 0; }
.account-title { font-weight: 500; }
.account-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row.status-bad .account-sub { color: var(--danger); }

/* ---------- новый канал ---------- */
.channel-add { color: var(--muted); margin-top: 0.25rem; }
.form-actions .spacer { flex: 1; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.template-card { display: flex; flex-direction: column; gap: 0.375rem; padding: 1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.template-card:hover { border-color: var(--border-strong); }
.template-card.active { border-color: var(--white); box-shadow: inset 0 0 0 1px var(--white); }
.template-card strong { font-size: 1rem; }
.template-card ul { margin: 0.25rem 0 0; padding-left: 1rem; font-size: 0.75rem; color: var(--muted); }
.wizard { display: flex; flex-direction: column; gap: 1.25rem; max-width: 56rem; }
.found-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.result-line { font-size: 0.8125rem; margin-top: 0.5rem; }
.result-line.ok { color: var(--text); }
.result-line.bad { color: var(--danger); }

/* ---------- автосбор ---------- */
.collect-box { display: flex; flex-direction: column; align-items: flex-end; gap: 0.375rem; }
.collect-info { font-size: 0.75rem; color: var(--muted); min-height: 1em; }
select.select { height: 2.25rem; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 0.375rem; padding: 0 0.5rem; font: 0.875rem var(--font); color-scheme: dark; }

/* ---------- режим выбора в ленте ---------- */
.item { border-left: 2px solid transparent; }
body.selecting .item { cursor: pointer; }
body.selecting .item .item-actions { visibility: hidden; }
.item.selected, .item.selected:hover { background: var(--surface-3); border-left-color: var(--white);
  box-shadow: inset 0 0 0 1px var(--white); }
.bulk-bar button:disabled { opacity: .45; cursor: default; }

/* ---------- публикации (боковая панель) ---------- */
.aside-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  border-bottom: 1px solid var(--border); padding-right: 0.5rem; }
.aside-head h2 { border-bottom: none; }
.sync-info { padding: 0.5rem 1rem; font-size: 0.75rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.sync-info:empty { display: none; }
.aside-sub { display: flex; justify-content: space-between; padding: 0.75rem 1rem 0.375rem; font-size: 0.6875rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 1px solid var(--border); }
.aside-sub:first-of-type { border-top: none; }
.aside-sub.danger { color: var(--danger, #e5484d); }
.aside-sub + .queue-item { border-top: none; }
.relative-time { color: var(--text-2); }
.queue-link { color: var(--muted); text-decoration: underline; }
.queue-link:hover { color: var(--text); }
a.queue-title { display: block; }
a.queue-title:hover { color: var(--text); }
.queue-error { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ---------- окно подтверждения ---------- */
.ask-dialog { max-width: 26rem; width: calc(100% - 2rem); }
.ask-text { line-height: 1.5; white-space: pre-line; }
.ask-input { width: 100%; margin-top: 0.75rem; }
.ask-buttons { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- оценка интересности ---------- */
.score { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.8125rem; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--text-2); font-variant-numeric: tabular-nums; }
.score-hot { background: var(--white); color: #000; border-color: var(--white); }

/* ---------- лента на узком экране: ничего не вылезает за край ---------- */
.feed-layout > section { min-width: 0; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs .tab { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  .toolbar-row { flex-wrap: wrap; }
  .toolbar-row input[type="search"] { flex-basis: 100%; }
}

/* ---------- вход ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 22rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 1.75rem; display: flex; flex-direction: column; gap: 1rem; }
.login-card h1 { font-size: 1.25rem; }
.user-box { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  font-size: 0.8125rem; color: var(--text-2); padding: 0.5rem 0; }

.admin-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-top: 1px solid var(--border); }
.admin-row > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.admin-add { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.admin-add input { flex: 1 1 12rem; }

/* ---------- статистика ---------- */
.stat-row { padding: 0.625rem 0; border-top: 1px solid var(--border); }
.stat-row:first-child { border-top: none; }
.stat-row-head { display: flex; justify-content: space-between; font-size: 0.875rem; }
.stat-bar { height: 0.5rem; background: var(--surface-3); border-radius: 0.25rem; margin: 0.375rem 0; overflow: hidden; }
.stat-bar > div { height: 100%; background: var(--white); }
.stats-channel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.5rem; }
.stat-big { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 3rem; margin-top: 0.5rem; }
.spark polyline { fill: none; stroke: var(--white); stroke-width: 2; vector-effect: non-scaling-stroke; }
.top-post { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.375rem 0;
  border-top: 1px solid var(--border); font-size: 0.8125rem; }
.top-post span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .stats-channel { grid-template-columns: 1fr; } }

.push-box { display: flex; flex-direction: column; gap: 1rem; }
.push-kinds { display: flex; flex-direction: column; gap: 0.5rem; }

/* ---------- телефон: нижнее меню, карточки, очередь ---------- */
.bottom-nav, .mobile-actions { display: none; }
@media (max-width: 860px) {
  body { padding-bottom: 4.5rem; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 6; background: var(--surface); border-top: 1px solid var(--border);
    padding: 0.375rem 0.25rem calc(0.375rem + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 0.125rem;
    font: 0.6875rem var(--font); color: var(--muted); background: none; border: none; padding: 0.25rem 0; }
  .bottom-nav .icon { width: 1.5rem; height: 1.5rem; padding: 0.125rem 1rem; border-radius: 1rem; box-sizing: content-box; }
  .bottom-nav .active { color: var(--text); }
  .bottom-nav .active .icon { background: var(--surface-3); }
  .mobile-bar button[aria-label="Меню"] { display: none; }
  body.menu-open .sidebar { position: fixed; inset: 3rem 0 4.5rem 0; overflow-y: auto; z-index: 7; background: var(--bg); }
  .item { border-radius: 1rem; margin: 0 0 0.5rem; border: 1px solid var(--border); }
  .list { border: none; background: none; }
  body.view-queue .feed-layout > section, body.view-queue .stats, body.view-queue .page-head { display: none; }
  body:not(.view-queue) .feed-layout > .aside-card { display: none; }
  .mobile-actions { display: flex; gap: 0.5rem; position: fixed; left: 0; right: 0; bottom: 4.25rem; z-index: 5;
    padding: 0.5rem 1rem; background: var(--bg); border-top: 1px solid var(--border); }
  .mobile-actions .btn { flex: 1; justify-content: center; min-height: 2.75rem; }
  .editor-layout .sticky { order: -1; }
}
@media (max-width: 860px) {
  .stats, .subfilters, .collect-info { display: none; }
  .filters .segmented.wrap { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters .segmented > * { flex: none; }
  .item-meta { flex-wrap: wrap; row-gap: 0.125rem; }
  .item-main { gap: 0.75rem; }
}
@media (max-width: 860px) {
  .page-head { flex-wrap: wrap; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .nav-row { flex-wrap: wrap; }
}

.item { transition: transform .15s; }
.item.swipe-skip { background: var(--surface-3); box-shadow: inset -3px 0 0 var(--danger); }
.item.swipe-open { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--white); }

/* ---------- варианты заголовка ---------- */
.title-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.625rem; }
.title-chips .chip { cursor: pointer; text-align: left; white-space: normal; height: auto; min-height: 1.75rem; padding: 0.3rem 0.625rem; }
.collect-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
