/* Интерфейс студии.
   Одна задача: показать текст поста ровно так, как его увидят в ленте, и
   дать два действия. Всё остальное вторично и не должно перетягивать внимание. */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --line: #dfe3e8;
    --text: #1a1d23;
    --muted: #616b7a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Шапка ─────────────────────────────────────────────────────────── */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.tabs { display: flex; gap: 4px; }

.tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); }

.budget {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
}

/* ─── Содержимое ────────────────────────────────────────────────────── */

main { max-width: 780px; margin: 0 auto; padding: 20px; }

.view { display: none; }
.view.active { display: block; }

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

.chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--surface-2); color: var(--text); border-color: transparent; }

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

/* ─── Карточка поста ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.state {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.state-ready      { background: rgba(74,222,128,.14); color: var(--ok); }
.state-rejected   { background: rgba(248,113,113,.14); color: var(--bad); }
.state-scheduled  { background: rgba(110,168,254,.14); color: var(--accent); }
.state-publishing { background: rgba(251,191,36,.14); color: var(--warn); }
.state-published  { background: rgba(154,163,178,.14); color: var(--muted); }
.state-failed     { background: rgba(248,113,113,.14); color: var(--bad); }
.state-drafted    { background: rgba(154,163,178,.14); color: var(--muted); }

.counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.counter.tight { color: var(--warn); }

/* Текст показывается ровно так, как его увидят в ленте: без переносов,
   без обрезки, с сохранением абзацев. Иначе решение принимается вслепую. */
.post-text {
  padding: 16px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.6;
}

.post-image {
  display: block;
  max-width: 100%;
  border-top: 1px solid var(--line);
}

.reason {
  margin: 0 16px 14px;
  padding: 10px 12px;
  background: rgba(248,113,113,.08);
  border-left: 3px solid var(--bad);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

button.primary, button.ghost, button.danger {
  padding: 7px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
}
button.primary { background: var(--accent); color: #0b1220; font-weight: 500; }
button.ghost   { background: transparent; color: var(--text); border-color: var(--line); }
button.danger  { background: transparent; color: var(--bad); border-color: var(--line); }
button:disabled { opacity: .45; cursor: not-allowed; }

.spacer { margin-left: auto; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

/* ─── Панель разбора ────────────────────────────────────────────────── */

.analysis {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--muted);
}
.analysis .status-line { flex: 1 1 auto; min-width: 220px; }
.analysis b { color: var(--text); font-weight: 500; }

.analysis .run-error {
  flex-basis: 100%;
  margin-top: 2px;
  padding: 8px 10px;
  background: rgba(248,113,113,.08);
  border-left: 3px solid var(--bad);
  border-radius: 0 8px 8px 0;
  overflow-wrap: anywhere;
}

.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 7px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ─── Настройки ─────────────────────────────────────────────────────── */

.settings {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.settings label, .dialog-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.settings input, .settings select,
.dialog-body input, .dialog-body select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.settings small, .dialog-body small, .hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.windows { display: flex; flex-direction: column; gap: 8px; }
.window-row { display: grid; grid-template-columns: 1fr 100px 100px auto; gap: 8px; align-items: end; }

/* ─── Репозитории ───────────────────────────────────────────────────── */

.repos { margin-bottom: 18px; gap: 12px; }
.repos h3 { margin: 0; }

.repo-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.repo-row input[type="checkbox"] { width: auto; margin: 0; }
.repo-name { overflow-wrap: anywhere; }
.repo-branch { font-size: 12.5px; color: var(--muted); }

.repo-add {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 620px) {
  .repo-add { grid-template-columns: 1fr; }
}

/* ─── Диалог ────────────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.5); }

.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.dialog-body h3 { margin: 0; font-size: 17px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ─── Уведомление ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 620px) {
  .top { flex-wrap: wrap; gap: 12px; }
  .budget { width: 100%; margin-left: 0; }
  .row, .window-row { grid-template-columns: 1fr; }
}
