:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1b1a17;
  --muted: #6b6860;
  --line: #e4e1da;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee6;
  --ok: #2b8a3e;
  --ok-soft: #e6f4ea;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --warn: #b35c00;
  --warn-soft: #fff3e0;
  --info: #1c64b4;
  --info-soft: #e7f0fb;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1d1c19;
    --text: #ecebe7;
    --muted: #9c988e;
    --line: #2f2d29;
    --accent: #ff7a3d;
    --accent-ink: #1b1a17;
    --accent-soft: #3a2216;
    --ok: #69db7c;
    --ok-soft: #15301c;
    --bad: #ff8787;
    --bad-soft: #3b1a1a;
    --warn: #ffb35c;
    --warn-soft: #3a2a12;
    --info: #74c0fc;
    --info-soft: #132a40;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
code, pre { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.err-text { color: var(--bad); }

.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.top nav a.on, .top nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.brand { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: -0.03em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 28px; margin-bottom: 8px; }
.logout { margin: 0; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.narrow { width: 100%; max-width: 400px; }
.card.empty { text-align: center; padding: 40px 20px; }
.card.empty h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }
details.card summary { cursor: pointer; color: var(--muted); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head h1 { margin: 0; }
.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > h2 { margin-bottom: 0; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } .top { gap: 12px; padding: 10px 16px; } .wrap { padding: 20px 16px 48px; } }
@media (max-width: 640px) { .top { flex-wrap: wrap; row-gap: 6px; } .top .brand { flex: 1; } .top nav { order: 3; flex-basis: 100%; margin: 0 -12px; } }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { opacity: .5; }
textarea { resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 8px; padding: 9px 16px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.ghost.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 13px; font-size: 16px; }
.btn.full { width: 100%; }
.btn.disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
button.link:hover { color: var(--text); }

.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.auth .flash { width: 100%; max-width: 400px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.warn b { color: var(--warn); }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--bg); }
.title { color: var(--text); font-weight: 600; }
.targets { display: flex; flex-wrap: wrap; gap: 6px; }
.tgt { display: inline-flex; align-items: center; gap: 4px; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.s-scheduled { background: var(--info-soft); color: var(--info); }
.s-running { background: var(--accent-soft); color: var(--accent); }
.s-published { background: var(--ok-soft); color: var(--ok); }
.s-failed { background: var(--bad-soft); color: var(--bad); }
.s-unconfirmed { background: var(--warn-soft); color: var(--warn); }
.s-cancelled { background: var(--bg); color: var(--muted); }

.pf { display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 4px; border-radius: 5px; font-size: 11px; font-weight: 800; color: #fff; vertical-align: middle; }
.pf-youtube { background: #e03131; }
.pf-facebook { background: #1877f2; }
.pf-instagram { background: linear-gradient(45deg, #f09433, #dc2743 55%, #bc1888); }
.pf-linkedin { background: #0a66c2; }
.pf-x { background: #111; border: 1px solid #444; }

.connect { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
ul.channels, ul.targets-list { list-style: none; margin: 0; padding: 0; }
ul.channels li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
ul.channels li:last-child { border-bottom: 0; }
ul.channels li form { margin: 0; }
ul.channels img, .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg); flex: none; }
ul.channels li.bad { background: linear-gradient(90deg, var(--bad-soft), transparent 60%); }
ul.targets-list li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
ul.targets-list li:last-child { border-bottom: 0; }
ul.targets-list .row { display: flex; align-items: center; gap: 8px; }
ul.targets-list form { margin: 4px 0 0; }
ul.targets-list a { word-break: break-all; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv-table { margin-top: 12px; border-collapse: collapse; font-size: 13px; }
.kv-table td { padding: 4px 12px 4px 0; }

.drop { position: relative; border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; font-weight: 500; background: var(--bg); }
.drop.hover, .drop:hover { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
video { width: 100%; max-height: 360px; border-radius: 8px; background: #000; }
.limits { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); }
.limits .over { color: var(--bad); font-weight: 600; }
.picks { display: flex; flex-direction: column; gap: 8px; }
.pick { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; padding: 6px 8px; border-radius: 8px; }
.pick:hover { background: var(--bg); }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { position: relative; height: 28px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.progress #bar { height: 100%; width: 0; background: var(--accent-soft); transition: width .2s; }
.progress #pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
pre.caption { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 14px; margin: 0; background: var(--bg); padding: 12px; border-radius: 8px; }
.live { color: var(--accent); font-weight: 600; }
