/* Narastilla SMM — в фирменном стиле CRM Narastilla:
   тёплый светлый фон, графитовый текст, графитовые основные кнопки,
   персиковые и шалфейные плашки статусов, шрифт Manrope, логотип разрядкой. */
:root {
  --bg: #f6f5f1;
  --sidebar: #eeece6;
  --panel: #fffefa;
  --head: #f3f1eb;
  --ink: #292824;
  --ink-2: #6a635b;
  --ink-3: #8a847d;
  --line: #e5e1d8;
  --badge: #edeae3;
  --accent: #292824;
  --accent-ink: #fffefa;
  --accent-soft: #fbefd9;
  --ok: #426c5e;
  --ok-soft: #eaf0e8;
  --err: #9b3d2c;
  --err-soft: #f6e4dd;
  --manual: #654714;
  --manual-soft: #fbefd9;
  --run: #7d5b2b;
  --radius-s: 8px;
  --radius-m: 12px;
  --shadow: 0 1px 2px rgba(41, 40, 36, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: var(--radius-s); padding: 7px 12px; cursor: pointer; font-size: 14px; font-weight: 500;
  min-height: 36px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; }
.feed { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.feed-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); letter-spacing: 0; }
.feed-filter { display: flex; gap: 4px; padding: 10px 16px 0; }
.chip-toggle {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 12px;
  font-size: 13px; cursor: pointer; color: var(--ink-2);
}
.chip-toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.feed-list { overflow-y: auto; padding: 10px 10px 24px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.feed-empty { padding: 24px 16px; color: var(--ink-2); font-size: 14px; }

.post-card {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start;
  padding: 10px; border-radius: var(--radius-m); cursor: pointer; border: 1px solid transparent;
  background: transparent; text-align: left; width: 100%;
}
.post-card:hover { background: var(--panel); }
.post-card[aria-current="true"] { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.thumb {
  width: 64px; height: 64px; border-radius: var(--radius-s); background: var(--line) center/cover no-repeat;
  position: relative; overflow: hidden;
}
.thumb .count, .thumb .play {
  position: absolute; font-size: 11px; font-weight: 600; color: #fff; background: rgba(20, 14, 28, .66);
  border-radius: 4px; padding: 0 5px; line-height: 18px;
}
.thumb .count { right: 3px; bottom: 3px; }
.thumb .play { left: 3px; bottom: 3px; }
.post-meta { min-width: 0; }
.post-date { font-size: 13px; color: var(--ink-3); }
.post-caption { font-size: 14px; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.post-caption.empty { color: var(--ink-3); }

/* «лесенка» площадок */
.ladder { display: flex; gap: 3px; margin-top: 6px; }
.rung {
  width: 22px; height: 18px; border-radius: 4px; font-size: 10px; font-weight: 700; line-height: 18px;
  text-align: center; background: transparent; border: 1px solid var(--line); color: var(--ink-3);
}
.rung.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.rung.manual { background: var(--manual-soft); border-color: var(--manual); color: var(--manual); }
.rung.error { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.rung.running { border-color: var(--run); color: var(--run); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .rung.running { animation: none; } }

/* ---------- рабочая область ---------- */
.work { overflow-y: auto; min-height: 0; }
.work-inner { max-width: 980px; margin: 0 auto; padding: 20px 28px 64px; }
.work-empty { height: 100%; display: grid; place-items: center; color: var(--ink-2); padding: 32px; text-align: center; }
.work-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.work-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.work-sub { color: var(--ink-3); font-size: 13px; }
.back { display: none; }

.media-strip { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; }
.media-item {
  flex: 0 0 auto; width: 132px; height: 132px; border-radius: var(--radius-m); background: var(--line) center/cover no-repeat;
  position: relative; overflow: hidden; display: grid; place-items: center; color: var(--ink-2); font-size: 12px; text-align: center;
}
.media-item a { position: absolute; inset: 0; }
.media-item .badge {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(20, 14, 28, .66); border-radius: 4px; padding: 0 6px; line-height: 18px;
}
.media-item.error { background: var(--err-soft); color: var(--err); padding: 8px; }
.media-item.pending { color: var(--ink-3); }

.caption-src { font-size: 14px; color: var(--ink-2); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 8px 10px; margin-top: 8px; white-space: pre-wrap; }

.section { margin-top: 22px; }
.section h2 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.hint { font-size: 13px; color: var(--ink-3); margin: -4px 0 8px; }

.brief { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; box-shadow: var(--shadow); }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
textarea, input[type="text"], input[type="password"], input[type="url"] {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-s);
  padding: 9px 11px; resize: vertical; line-height: 1.5;
}
textarea:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.brief-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gen-status { font-size: 13px; color: var(--ink-2); }
.gen-status.error { color: var(--err); }
.summary { font-size: 14px; color: var(--ink-2); margin-top: 10px; }
.summary b { color: var(--ink); font-weight: 600; }

/* площадки */
.platform-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ptab {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.ptab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: 0 0 auto; }
.dot.ok { background: var(--ok); } .dot.manual { background: var(--manual); } .dot.error { background: var(--err); }
.dot.running { background: var(--run); animation: pulse 1.2s infinite; }

.editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; box-shadow: var(--shadow); }
.editor textarea { min-height: 220px; }
.editor textarea.short { min-height: 0; }
.counter { font-size: 12px; color: var(--ink-3); text-align: right; margin-top: 2px; }
.counter.over { color: var(--err); font-weight: 600; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.editor-actions .spacer { flex: 1; }
.pub-state { font-size: 13px; margin-top: 10px; padding: 8px 10px; border-radius: var(--radius-s); }
.pub-state.ok { background: var(--ok-soft); color: var(--ok); }
.pub-state.manual { background: var(--manual-soft); color: var(--manual); }
.pub-state.error { background: var(--err-soft); color: var(--err); white-space: pre-wrap; }
.pub-state.running { background: var(--accent-soft); color: var(--ink-2); }
.pub-state a { color: inherit; font-weight: 600; }
.note { font-size: 13px; color: var(--ink-3); }

/* ---------- настройки ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-m); padding: 0; width: min(860px, calc(100vw - 24px));
  max-height: calc(100vh - 40px); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 14, 28, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100vh - 180px); }
.dlg-body textarea { min-height: 160px; font-size: 14px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }

/* ---------- уведомления ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: var(--radius-s); font-size: 14px; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--err); color: #fff; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px; box-shadow: var(--shadow); }
.login h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.login p { color: var(--ink-2); margin: 0 0 18px; font-size: 14px; }
.login .error { color: var(--err); font-size: 14px; min-height: 21px; margin: 8px 0 0; }
.login .btn { width: 100%; margin-top: 12px; min-height: 42px; }

/* ---------- телефон ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .app.has-post .feed { display: none; }
  .app:not(.has-post) .work { display: none; }
  .feed { border-right: 0; }
  .work-inner { padding: 12px 16px 48px; }
  .back { display: inline-flex; }
  .media-item { width: 104px; height: 104px; }
}

a { color: var(--accent); }
a.btn { color: var(--ink); text-decoration: none; }

/* ---------- фирменный слой Narastilla ---------- */
body { font-size: 15px; letter-spacing: -.003em; }
.logo { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-word {
  font-family: "Montserrat", "Manrope", sans-serif; font-weight: 600; font-size: 19px;
  letter-spacing: .17em; line-height: 1; color: #232121;
}
.logo-tag {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--ink-2);
  background: var(--badge); border-radius: 6px; padding: 3px 7px; line-height: 1;
}

.feed { background: var(--sidebar); }
.feed-head { flex-direction: column; align-items: stretch; gap: 14px; padding: 26px 18px 16px; border-bottom: 0; }
.feed-tools { display: flex; justify-content: space-between; align-items: center; }
.feed-tools .label { font-size: 13px; color: var(--ink-2); }
.feed-filter { padding: 0 18px 4px; gap: 6px; }
.chip-toggle {
  border-radius: var(--radius-s); background: var(--panel); border-color: var(--line);
  color: var(--ink); font-weight: 500; padding: 6px 12px; font-size: 13px;
}
.chip-toggle[aria-pressed="true"] { background: var(--ink); color: var(--accent-ink); border-color: var(--ink); }
.post-card:hover { background: rgba(255, 254, 250, .6); }
.post-card[aria-current="true"] { background: var(--panel); border-color: var(--line); box-shadow: none; }
.thumb { border-radius: var(--radius-s); }

.rung { border-radius: 5px; background: var(--panel); border-color: var(--line); }
.rung.ok { background: var(--ok-soft); border-color: #cfdccb; color: var(--ok); }
.rung.manual { background: var(--manual-soft); border-color: #eedcb8; color: var(--manual); }
.rung.error { background: var(--err-soft); border-color: #ebc9bd; color: var(--err); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 76px; padding: 0 50px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { font-size: 14px; color: var(--ink-2); }
.crumbs b { color: var(--ink); font-weight: 500; }
.crumbs span { margin: 0 12px; color: var(--ink-3); }
.infobar {
  background: #efede6; color: var(--ink-2); font-size: 12px; padding: 9px 50px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.work { background: var(--bg); }
.work-inner { padding: 36px 50px 64px; max-width: 1040px; margin: 0; }
.work-title { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.work-sub { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.work-empty { height: calc(100% - 114px); }

.brief, .editor { border-radius: var(--radius-m); box-shadow: none; padding: 18px; }
.section h2 { font-size: 16px; font-weight: 600; }
.caption-src { background: var(--head); border-style: solid; }

.ptab { border-radius: var(--radius-s); font-weight: 500; }
.ptab[aria-selected="true"] { background: var(--ink); color: var(--accent-ink); border-color: var(--ink); }
.ptab[aria-selected="true"] .dot:not(.ok):not(.manual):not(.error):not(.running) { background: #6a635b; }
.dot.ok { background: #6f9c7b; }
.dot.manual { background: #d2a45a; }

.pub-state.ok { color: var(--ok); }
.pub-state.running { background: #f4e5c9; color: var(--run); }

textarea:focus, input:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(41, 40, 36, .08); }
:focus-visible { outline-color: var(--ink); }
.btn { border-radius: var(--radius-s); background: var(--panel); }
.btn-ghost { background: transparent; }
a { color: var(--ink); text-underline-offset: 2px; }

.login { background: var(--bg); }
.login form { border-radius: var(--radius-m); box-shadow: none; padding: 32px 28px; }
.login .logo { margin-bottom: 22px; }
.login h1 { font-size: 22px; font-weight: 600; }

@media (max-width: 820px) {
  .topbar { height: 60px; padding: 0 16px; }
  .infobar { padding: 8px 16px; }
  .work-inner { padding: 20px 16px 48px; }
  .work-title { font-size: 24px; }
}
.mobile-only { display: none; }
@media (max-width: 820px) {
  .mobile-only { display: inline-flex; gap: 2px; }
  .topbar .btn { display: none; }
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #3a3833; border-color: #3a3833; filter: none; }
.vk-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--head); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; }
.vk-actions { display: flex; gap: 6px; }
a.btn-primary { color: var(--accent-ink); }
