:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #171923;
  --muted: #6b7084;
  --line: #e4e6ee;
  --soft: #f0f1f6;
  --accent: #5b4cf0;
  --accent-soft: #ecebff;
  --ok: #12925a;
  --ok-soft: #e3f6ec;
  --bad: #d23a3a;
  --bad-soft: #fdeaea;
  --warn: #b26a00;
  --warn-soft: #fff3dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 40, .05), 0 4px 16px rgba(20, 22, 40, .05);
  --x: #111111;
  --facebook: #1877f2;
  --instagram: #d62976;
  --threads: #3a3a3a;
  --youtube: #e62117;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1016;
    --card: #181a23;
    --text: #eceef5;
    --muted: #9196aa;
    --line: #2a2d3a;
    --soft: #20232f;
    --accent: #8578ff;
    --accent-soft: #262249;
    --ok: #3ccf8a;
    --ok-soft: #12301f;
    --bad: #ff6b6b;
    --bad-soft: #3a1717;
    --warn: #f0b04a;
    --warn-soft: #3a2a10;
    --shadow: none;
    --x: #e7e7e7;
    --threads: #cfcfcf;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, 'Noto Sans Devanagari', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 700; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab {
  border: 0; background: none; padding: 7px 13px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tab:hover { background: var(--soft); color: var(--text); }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 8px; }
.me-name { font-size: 13px; color: var(--muted); }
main { max-width: 1120px; margin: 0 auto; padding: 22px 16px 80px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stack > * + * { margin-top: 14px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--card);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 12px 22px; font-size: 16px; border-radius: 12px; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: none; }
label.f { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 130px; line-height: 1.55; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { margin-bottom: 18px; }
.err { background: var(--bad-soft); color: var(--bad); padding: 9px 12px; border-radius: 10px; font-size: 14px; white-space: pre-line; }
.note { background: var(--warn-soft); color: var(--warn); padding: 9px 12px; border-radius: 10px; font-size: 14px; }
.okmsg { background: var(--ok-soft); color: var(--ok); padding: 9px 12px; border-radius: 10px; font-size: 14px; }

/* ---------- platform pill ---------- */
.pp { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #fff; background: var(--c, #888); }
.pp.x { --c: var(--x); color: var(--bg); }
.pp.facebook { --c: var(--facebook); }
.pp.instagram { --c: var(--instagram); }
.pp.threads { --c: var(--threads); color: var(--bg); }
.pp.youtube { --c: var(--youtube); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #888); display: inline-block; flex: none; }
.dot.x { --c: var(--x); } .dot.facebook { --c: var(--facebook); } .dot.instagram { --c: var(--instagram); }
.dot.threads { --c: var(--threads); } .dot.youtube { --c: var(--youtube); }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--soft); flex: none; display: grid; place-items: center; font-weight: 600; color: var(--muted); }

/* ---------- composer ---------- */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .compose { grid-template-columns: 1fr; } }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; cursor: pointer; color: var(--muted);
  transition: .15s; background: var(--soft);
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 2px; }
.preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; display: grid; place-items: center; }
.preview img, .preview video { max-width: 100%; max-height: 380px; display: block; }
.preview .x-btn { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.65); color: #fff; border: 0; border-radius: 99px; padding: 5px 11px; cursor: pointer; font-size: 13px; }
.preview .meta { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; border-radius: 8px; padding: 3px 8px; font-size: 12px; }
.progress { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.counters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.counter { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.counter.over { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.ov-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.ov-box textarea { min-height: 80px; }
.seg { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 10px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.acc-list { display: flex; flex-direction: column; gap: 6px; }
.acc {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  background: var(--card); text-align: left; width: 100%; transition: .12s;
}
.acc:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.acc.on { border-color: var(--accent); background: var(--accent-soft); }
.acc.off { opacity: .55; }
.acc .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc .why { font-size: 12px; color: var(--warn); }
.check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: #fff; font-size: 13px; }
.acc.on .check { background: var(--accent); border-color: var(--accent); }
.side { position: sticky; top: 74px; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }

/* ---------- history ---------- */
.post { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
@media (max-width: 560px) { .post { grid-template-columns: 1fr; } }
.thumb { width: 96px; height: 96px; border-radius: 10px; background: var(--soft); object-fit: cover; display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; }
.cap { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--soft); text-decoration: none; color: var(--text); max-width: 100%; }
.tg.success { background: var(--ok-soft); }
.tg.failed { background: var(--bad-soft); }
.tg .st { font-weight: 600; font-size: 12px; }
.tg.success .st { color: var(--ok); }
.tg.failed .st { color: var(--bad); }
.tg.running .st, .tg.pending .st { color: var(--accent); }
.tg-err { font-size: 12px; color: var(--bad); margin-top: 4px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.badge.published { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.partial { background: var(--warn-soft); color: var(--warn); }
.badge.processing, .badge.queued { background: var(--accent-soft); color: var(--accent); }
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- accounts / team ---------- */
.connect-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.connector { display: flex; flex-direction: column; gap: 10px; }
.connector .row { justify-content: space-between; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; word-break: break-all; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); white-space: pre-line; animation: up .2s; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 680px) {
  .top-in { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .me-name, .me .ghost { display: none; }
  main { padding: 16px 12px 60px; }
  .side { position: static; }
}

.masked { -webkit-text-security: disc; text-security: disc; font-family: monospace; }

.brand-group + .brand-group { margin-top: 10px; }
.brand-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 2px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.brand-head strong { color: var(--text); }
.brand-group > .acc + .acc { margin-top: 6px; }
.brand-block + .brand-block { margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--line); }
.brand-title { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }

.step { padding: 18px 18px 20px; }
.step-head { display: flex; gap: 12px; align-items: flex-start; cursor: default; list-style: none; }
details.step > summary { cursor: pointer; }
details.step > summary::-webkit-details-marker { display: none; }
.step-no { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.brand-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 14px; }
.btab { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; }
.btab .cnt { background: var(--soft); color: var(--muted); font-size: 12px; padding: 0 7px; border-radius: 99px; }
.btab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btab.on .cnt { background: rgba(255,255,255,.25); color: #fff; }
.btab.add { border-style: dashed; color: var(--accent); font-weight: 500; }
.brand-panel { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--bg); }
.connect-tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.connect-tile .btn { white-space: normal; }
