:root {
  --font: "Century Gothic", CenturyGothic, "URW Gothic", "URW Gothic L", AppleGothic, "Avant Garde", sans-serif;
  --ink: #111;
  --ink-2: #555;
  --ink-3: #8a8a8a;
  --line: #e4e2dd;
  --bg: #f6f5f2;
  --card: #fff;
  --accent: #111;
  --fb: #1b74e4;
  --ig: #c2307f;
  --ok: #1e8a4c;
  --ok-bg: #e5f4ea;
  --warn: #a8620a;
  --warn-bg: #fdf1dc;
  --bad: #c4302b;
  --bad-bg: #fbe6e4;
  --info: #2c5d9e;
  --info-bg: #e7eef8;
  --sched: #2c5d9e;
  --sched-bg: #e7eef8;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 26px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-top: 1.6em; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; background: #efeee9; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.warn { color: var(--bad); font-weight: 700; }
.inline { display: inline; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: #fff; border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; align-self: start;
}
.brand { font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: -0.02em; }
.brand span { font-weight: 400; }
.brand.big { font-size: 28px; text-align: center; margin-bottom: 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); }
.side nav a:hover { background: var(--bg); color: var(--ink); }
.side nav a.on { background: var(--ink); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }

.page-head { margin-bottom: 22px; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 700;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #bdbab3; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

input[type=text], input[type=password], input[type=datetime-local], textarea, select {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
label { display: block; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; }
.stack.narrow { max-width: 360px; }
.row-form { display: flex; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ---------- flashes & banners ---------- */
.flash, .banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--info-bg); color: var(--info); }
.banner { background: #fff; border: 1px solid var(--line); }
.banner-test { background: #111; color: #fff; }
.banner-test code { background: #333; color: #fff; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- badges & pills ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #eee; color: var(--ink-2); white-space: nowrap; }
.badge.st-scheduled { background: var(--sched-bg); color: var(--sched); }
.badge.st-processing { background: var(--warn-bg); color: var(--warn); }
.badge.st-published { background: var(--ok-bg); color: var(--ok); }
.badge.st-partial { background: var(--warn-bg); color: var(--warn); }
.badge.st-failed { background: var(--bad-bg); color: var(--bad); }
.type { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border: 1px solid var(--ink); border-radius: 4px; }
.type-reel { background: var(--ink); color: #fff; }
.type-story { border-style: dashed; }

.pf { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 10px; font-weight: 700; color: #fff; flex: none; position: relative; }
.pf-facebook { background: var(--fb); }
.pf-instagram { background: var(--ig); }
.pf.ts-published::after, .pf.ts-failed::after, .pf.ts-processing::after {
  content: ""; position: absolute; right: -4px; bottom: -4px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid #fff;
}
.pf.ts-published::after { background: var(--ok); }
.pf.ts-failed::after { background: var(--bad); }
.pf.ts-processing::after { background: #e8a33b; }

/* ---------- queue ---------- */
.q-section { margin-bottom: 30px; }
.q-section h2 .count { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.q-section.attention h2 { color: var(--bad); }
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-day { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 10px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.post-card { display: flex; gap: 14px; padding: 12px; text-decoration: none; transition: border-color .15s; }
.post-card:hover { border-color: #b9b5ac; }
.thumb { width: 74px; height: 74px; border-radius: 8px; overflow: hidden; flex: none; background: #eceae4; position: relative; }
.thumb img, .thumb video, .mthumb img, .mthumb video, .pv-fill img, .pv-fill video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: grid; place-items: center; color: var(--ink-3); font-weight: 700; }
.play { position: absolute; inset: auto 6px 6px auto; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; border-radius: 4px; padding: 1px 5px; }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pc-top { display: flex; align-items: center; gap: 10px; }
.pc-when { margin-left: auto; font-size: 13px; font-weight: 700; }
.pc-caption { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.acct { color: var(--ink-2); margin-right: 8px; }

.empty { text-align: center; padding: 50px 20px; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- calendar ---------- */
.cal-nav { display: flex; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: #fff; border-radius: var(--radius); overflow: hidden; }
.cal-h { padding: 8px 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-d { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.cal-d.out { background: #faf9f6; }
.cal-d.out .cal-num span { color: #c8c5be; }
.cal-num { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; padding: 0 2px; }
.cal-d.today .cal-num span { background: var(--ink); color: #fff; border-radius: 99px; padding: 0 7px; }
.cal-add { text-decoration: none; color: var(--ink-3); opacity: 0; font-size: 16px; line-height: 1; padding: 0 4px; }
.cal-d:hover .cal-add { opacity: 1; }
.chip { display: flex; gap: 5px; align-items: center; font-size: 11.5px; padding: 3px 6px; border-radius: 5px; text-decoration: none; background: #eee; overflow: hidden; white-space: nowrap; }
.chip-time { font-weight: 700; }
.chip-pf { font-weight: 700; letter-spacing: .04em; opacity: .75; }
.chip.st-scheduled, .chip.st-processing { background: var(--sched-bg); color: var(--sched); }
.chip.st-published { background: var(--ok-bg); color: var(--ok); }
.chip.st-partial { background: var(--warn-bg); color: var(--warn); }
.chip.st-failed { background: var(--bad-bg); color: var(--bad); }
.chip.st-draft { background: #fff; border: 1px dashed #c8c5be; color: var(--ink-2); }
.legend { margin-top: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.lg.st-scheduled { background: var(--sched-bg); border: 1px solid var(--sched); }
.lg.st-draft { border: 1px dashed #aaa; }
.lg.st-published { background: var(--ok-bg); border: 1px solid var(--ok); }
.lg.st-failed { background: var(--bad-bg); border: 1px solid var(--bad); }

/* ---------- compose ---------- */
.compose { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
.block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 14px; }
fieldset.block legend { font-weight: 700; padding: 0 6px; margin-left: -6px; }
details.block summary { cursor: pointer; font-weight: 700; }
details.block[open] summary { margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg-opt { cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: block; padding: 8px 22px; font-weight: 700; font-size: 14px; }
.seg-opt + .seg-opt span { border-left: 1px solid var(--ink); }
.seg-opt input:checked + span { background: var(--ink); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--fb); outline-offset: -3px; }
.hint { margin: 10px 0 0; color: var(--ink-2); display: none; }
.compose[data-type=post] .hint[data-for=post],
.compose[data-type=reel] .hint[data-for=reel],
.compose[data-type=story] .hint[data-for=story] { display: block; }

.acct-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-opt { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 9px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: 14px; }
.acct-opt:has(input:checked) { border-color: var(--ink); background: #f3f2ee; }
.acct-opt.inactive { opacity: .7; }
.acct-opt input { margin: 0; }

.drop { border: 1.5px dashed #bcb8af; border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer; position: relative; margin-top: 10px; }
.drop:hover, .drop.over { border-color: var(--ink); background: #faf9f6; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.media-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.media-grid:empty { display: none; }
.media-grid.existing { margin-top: 0; }
.media-item { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; cursor: grab; }
.media-item.dragging { opacity: .4; }
.mthumb { width: 104px; height: 104px; border-radius: 8px; overflow: hidden; background: #eceae4; position: relative; }
.media-grid.big .mthumb { width: 150px; height: 150px; }
.small-thumb { width: 56px; height: 56px; }
.media-item .rm { font-size: 12px; display: flex; gap: 4px; align-items: center; color: var(--bad); }
.media-item:has(.rm input:checked) .mthumb { opacity: .3; }
.dims { color: var(--ink-3); }
.reel-only { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.compose[data-type=reel] .reel-only { display: block; }
.compose[data-type=story] .no-story { display: none; }
.cover-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.counter { text-align: right; margin-top: 4px; }
.counter .over { color: var(--bad); font-weight: 700; }
.overrides { margin-top: 10px; }
.overrides summary { cursor: pointer; font-size: 14px; color: var(--ink-2); }
.overrides label { margin-top: 10px; font-size: 14px; font-weight: 700; }
.overrides textarea { margin-top: 4px; font-weight: 400; }
.when { display: flex; gap: 20px; flex-wrap: wrap; }
.sched { margin-top: 12px; font-size: 14px; font-weight: 700; max-width: 300px; }
.sched input { margin-top: 4px; }
.compose:has(input[name=when][value=now]:checked) .sched { display: none; }
.actions { display: flex; gap: 10px; align-items: center; }

.preview { position: sticky; top: 24px; }
.phone { background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.ph-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; font-weight: 700; }
.ph-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #ddd, #bbb); }
.ph-media { aspect-ratio: 4 / 5; background: #eceae4; position: relative; overflow: hidden; }
.compose[data-type=reel] .ph-media, .compose[data-type=story] .ph-media { aspect-ratio: 9 / 16; }
.pv-fill { position: absolute; inset: 0; }
.pv-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); }
.pv-count { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 99px; }
.ph-cap { padding: 10px 12px 14px; font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: hidden; }
.compose[data-type=story] .ph-cap { display: none; }

/* ---------- post view ---------- */
.post-view { display: grid; grid-template-columns: 1.3fr 1fr; gap: 30px; }
.caption-full { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; white-space: normal; word-break: break-word; }
.targets { display: flex; flex-direction: column; gap: 8px; }
.target { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.t-head { display: flex; align-items: center; gap: 8px; }
.t-head .badge { margin-left: auto; }
.t-error { color: var(--bad); background: var(--bad-bg); padding: 6px 8px; border-radius: 6px; }
.log-list { list-style: none; padding: 0; margin: 0; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.lv-error { color: var(--bad); }
.lv-success { color: var(--ok); }
.lv-warning { color: var(--warn); }
.lv-debug { color: var(--ink-3); }

/* ---------- accounts ---------- */
.acct-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.acct-row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.acct-row.inactive { opacity: .6; }
.acct-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e4e2dd; object-fit: cover; flex: none; }
.kv { border-collapse: collapse; width: 100%; font-size: 14px; }
.kv th { text-align: left; font-weight: 700; padding: 6px 16px 6px 0; width: 170px; vertical-align: top; }
.kv td { padding: 6px 0; }
.log-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.log-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lvl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* ---------- auth ---------- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 34px; width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 22px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .compose-btn { width: auto; margin-left: auto; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 50px; }
  .compose, .post-view { grid-template-columns: 1fr; }
  .preview { position: static; max-width: 300px; margin: 0 auto; }
  .cal-d { min-height: 80px; padding: 3px; }
  .chip-type, .chip-pf { display: none; }
  .post-card .pc-when { font-size: 12px; }
}
