/* МСЕ · вычитка постов. Токены и вид — как у «Студии текстов» Кредо (post-editor/static/style.css),
   чтобы оба редактора выглядели одинаково; без чужих правил (выплаты, специалисты). */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e4ea;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #059669;
  --error-bg: #fef2f2;
  --error-text: #dc2626;
  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --tg-bg: #dfe7ee;
  --tg-link: #2a7ab8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}

header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-weight: 600; flex-wrap: wrap;
}
.who { font-weight: 400; font-size: 14px; color: var(--text-muted); }
.logout-link { color: var(--text-muted); }
.logout-link:hover { color: var(--text); }

main { max-width: 1180px; margin: 24px auto; padding: 0 16px 60px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.muted { color: var(--text-muted); font-size: 14px; }
.alert-error { background: var(--error-bg); color: var(--error-text); padding: 10px 14px; border-radius: 8px; margin: 8px 0; }

/* ─── Вход ─── */
.login-card { max-width: 400px; margin: 60px auto; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .muted { margin-bottom: 20px; }
.login-card label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.login-card input { margin-top: 6px; }

input[type="text"], input[type="password"], textarea, select {
  border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px; font-size: 15px;
  font-family: inherit; color: var(--text); background: #fff; width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 8px;
  padding: 10px 22px; font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-full { width: 100%; }

/* ─── Вкладки каналов ─── */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: var(--radius); text-decoration: none; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.tab .count { opacity: .75; margin-left: 4px; }

.hint { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; max-width: 820px; }

/* ─── Пост-аккордеон ─── */
.post { padding: 0; }
.post-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; cursor: pointer; list-style: none; user-select: none;
}
.post-head::-webkit-details-marker { display: none; }
.post-head::before { content: "▸"; color: var(--text-muted); font-size: 12px; transition: transform .15s; }
.post[open] > .post-head::before { transform: rotate(90deg); }
.post[open] > .post-head { border-bottom: 1px solid var(--border); }
.post-head:hover { background: var(--bg); }
.day { font-weight: 600; font-size: 14px; color: var(--text-muted); white-space: nowrap; }
.head-title { font-weight: 600; flex: 1; min-width: 200px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
}
.badge-soon { background: #eef2ff; border-color: #c7d2fe; color: var(--primary); }
.badge-warn { background: var(--warn-bg); border-color: #fde68a; color: var(--warn-text); }
.badge-edited { background: #ecfdf5; border-color: #a7f3d0; color: var(--success); }
.badge-dirty { background: var(--warn-bg); border-color: #fde68a; color: var(--warn-text); }
.post-body { padding: 6px 18px 18px; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 24px; align-items: start; }
.col-preview { position: sticky; top: 12px; }
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .col-preview { position: static; }
}

.field-label {
  display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 14px 0 6px;
}
.title-field { font-weight: 600; font-size: 16px; line-height: 1.4; resize: none; overflow: hidden; }
.body-field { min-height: 320px; line-height: 1.55; font-size: 15px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.note-field { font-size: 14px; }

.toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.tb {
  min-width: 32px; height: 32px; padding: 0 10px; font-size: 14px; line-height: 1; font-family: inherit;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.tb:hover { background: var(--bg); border-color: var(--primary); }
.counter { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--error-text); font-weight: 600; }

/* ─── Проверки ─── */
.checks { margin-top: 12px; font-size: 14px; }
.checks ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 8px; }
.checks li.err { background: var(--error-bg); color: var(--error-text); }
.checks li.warn { background: var(--warn-bg); color: var(--warn-text); }
.checks .ok { color: var(--success); }
.checks .lead { font-size: 12px; color: var(--text-muted); margin: 8px 0 4px; }

.marks { margin-top: 12px; }
.mark {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.mark span { flex: 1; }
.mark i { color: var(--text-muted); }
.mark-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; text-decoration: underline; }
.mark-del:hover { color: var(--error-text); }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.save-status { font-size: 14px; }
.save-status.ok { color: var(--success); }
.save-status.err { color: var(--error-text); }

/* ─── Как в Telegram ─── */
.tg { background: var(--tg-bg); border-radius: var(--radius); padding: 14px; }
.bubble {
  background: #fff; border-radius: 12px 12px 12px 4px; padding: 10px 12px; font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.08); min-height: 60px;
}
.bubble a { color: var(--tg-link); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
.bubble a.plan-link { border-bottom: 1px dashed var(--tg-link); }
.bubble a.bad-link { color: var(--error-text); border-bottom: 1px dashed var(--error-text); }
.bubble blockquote {
  border-left: 3px solid var(--tg-link); background: #eef5fb; padding: 4px 10px; border-radius: 4px; margin: 2px 0;
}

/* ─── История правок и вышедшие ─── */
.history { margin-top: 18px; font-size: 14px; }
.history > summary, .done > summary { cursor: pointer; color: var(--text-muted); }
.history > summary:hover, .done > summary:hover { color: var(--text); }
.h-item { border-top: 1px solid var(--border); padding: 10px 0; }
.h-head { font-weight: 600; margin-bottom: 4px; }
.h-note { color: var(--text-muted); margin-bottom: 6px; }
ul.h-note { list-style: none; }
.h-diff {
  white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 13px;
  max-height: 320px; overflow: auto; overflow-wrap: anywhere;
}
.h-diff del { background: #fee2e2; color: #991b1b; }
.h-diff ins { background: #dcfce7; color: #166534; text-decoration: none; }
.done ul { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.done a { color: var(--primary); }

/* ─── Окна ссылки и замены ─── */
.dlg {
  border: none; border-radius: var(--radius); padding: 22px 24px; width: min(520px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,.18); color: var(--text); background: var(--surface); margin: auto;
}
.dlg::backdrop { background: rgba(15,17,26,.45); }
.dlg h3 { font-size: 17px; margin-bottom: 12px; }
.dlg label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.dlg input, .dlg select, .dlg textarea { margin-top: 5px; }
.dlg-quote { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; overflow-wrap: anywhere; }
.dlg-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.dlg-error { font-size: 13px; color: var(--error-text); margin-bottom: 10px; }
.dlg-actions { display: flex; gap: 8px; }

[hidden] { display: none !important; }
