:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --border: #2a2f3a;
  --text: #e8eaf0; --muted: #8b93a7; --accent: #6c8cff; --accent-2: #4f6fe0;
  --ok: #3ccf7a; --warn: #f0b740; --err: #ff6b6b; --fb: #1877f2; --ig: #e1306c;
  --radius: 12px; --shadow: 0 10px 40px rgba(0,0,0,.45);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f8; --panel: #fff; --panel-2: #f7f8fb; --border: #e3e6ee; --text: #171a21; --muted: #6b7386; --shadow: 0 10px 40px rgba(20,30,60,.12); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--err); font-size: 13px; min-height: 1em; margin: 6px 0 0; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
a { color: var(--accent); }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--panel-2); border-radius: 9px; padding: 9px 14px; cursor: pointer; font-weight: 500; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--muted); padding: 4px 8px; }
.icon:hover { color: var(--text); }

/* login */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.logo { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
input[type=text], input[type=url], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .4px; }

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav { text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.active { background: var(--panel-2); color: var(--text); }
.sidebar-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; padding: 0 12px; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.ch-row { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.ch-row.off { opacity: .45; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); flex: none; object-fit: cover; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.fb { background: var(--fb); } .avatar.ig { background: linear-gradient(45deg,#f9ce34,#ee2a7b,#6228d7); }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 20px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view { padding: 20px 24px; overflow: auto; flex: 1; }


/* post card */
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-size: 13px; transition: .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-top { display: flex; align-items: center; gap: 6px; }
.card-time { font-weight: 600; font-size: 12px; }
.card-body { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); line-height: 1.35; }
.card-media { display: flex; gap: 4px; }
.card-media img, .card-media video { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.dots { display: flex; gap: 3px; margin-left: auto; }
.dot { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; }
.dot.fb { background: var(--fb); } .dot.ig { background: var(--ig); } .dot.x { background: #555; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 600; }
.badge.draft { background: #3a3f4a; color: #cfd4e0; } .badge.scheduled { background: rgba(108,140,255,.18); color: var(--accent); }
.badge.publishing { background: rgba(240,183,64,.18); color: var(--warn); } .badge.published { background: rgba(60,207,122,.16); color: var(--ok); }
.badge.partial { background: rgba(240,183,64,.18); color: var(--warn); } .badge.failed { background: rgba(255,107,107,.16); color: var(--err); }

/* list */
.list { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.list .card { flex-direction: row; align-items: flex-start; gap: 14px; padding: 12px 14px; }
.list .card-media img, .list .card-media video { width: 64px; height: 64px; }
.list .card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.list-group { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 6px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }
.target-line { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.target-line .ok { color: var(--ok); } .target-line .err { color: var(--err); }

/* media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.media-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: var(--panel-2); cursor: pointer; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; }
.media-tile.selected { border-color: var(--accent); }
.media-tile .del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 6px; padding: 2px 6px; cursor: pointer; font-size: 12px; }
.media-tile .name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* channels view */
.channel-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
.channel-card .avatar { width: 40px; height: 40px; }
.channel-card .grow { flex: 1; min-width: 0; }
.connect-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; max-width: 640px; margin-bottom: 20px; }
.connect-box h3 { margin: 0 0 6px; }
.help { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.switch { position: relative; width: 38px; height: 22px; background: var(--border); border-radius: 999px; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch.on { background: var(--ok); } .switch.on::after { left: 19px; }

/* logs */
.log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.log .at { color: var(--muted); white-space: nowrap; }
.log.error { color: var(--err); } .log.warn { color: var(--warn); }

/* modal / composer */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 1040px; max-height: 94vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-card.narrow { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.composer-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; padding: 6px 22px 18px; overflow: auto; }
.composer-left label:first-child { margin-top: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--panel-2); border: none; padding: 8px 16px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: #fff; }
.fmt { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: rgba(225,48,108,.18); color: var(--ig); text-transform: uppercase; letter-spacing: .3px; }
.fmt.story { background: rgba(240,183,64,.18); color: var(--warn); }
#composerFormatHint { margin-top: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--panel-2); padding: 6px 10px 6px 6px; border-radius: 999px; cursor: pointer; font-size: 13px; transition: .15s; user-select: none; }
.chip .avatar { width: 24px; height: 24px; font-size: 10px; }
.chip.on { border-color: var(--accent); background: rgba(108,140,255,.12); }
.media-strip { display: flex; gap: 8px; flex-wrap: wrap; min-height: 10px; margin-bottom: 8px; }
.media-strip .thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.media-strip .thumb img, .media-strip .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-strip .thumb button { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 5px; font-size: 11px; cursor: pointer; padding: 1px 5px; }
.composer-preview { margin-top: 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.preview-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.preview-name { font-weight: 600; font-size: 14px; }
.preview-body { white-space: pre-wrap; font-size: 14px; line-height: 1.45; word-break: break-word; }
.preview-media { display: grid; gap: 4px; margin-top: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.preview-media img, .preview-media video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.targets { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; }
.toast.err { border-color: var(--err); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 10px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-channels { display: none; }
  .sidebar-footer { margin: 0; flex-direction: row; }
  .composer-grid { grid-template-columns: 1fr; }
}

label.btn { display: inline-block; margin: 0; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500; }

/* ===================== calendar ===================== */
.calbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.navgrp { display: flex; gap: 4px; }
.callabel { font-weight: 600; min-width: 170px; }
.seg.small button { padding: 6px 12px; font-size: 13px; }

/* week */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.wday { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 62vh; overflow: hidden; }
.wday.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.wday.past { opacity: .7; }
.whead { display: flex; align-items: baseline; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.whead b { font-size: 18px; color: var(--text); letter-spacing: 0; }
.wday.today .whead b { color: var(--accent); }
.whead em { margin-left: auto; font-style: normal; font-size: 11px; background: var(--panel-2); border-radius: 999px; padding: 1px 7px; }
.wbody { display: flex; flex-direction: column; gap: 6px; padding: 8px; flex: 1; }

.ccard { position: relative; background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 7px 8px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; min-width: 0; transition: border-color .15s, transform .15s; }
.ccard:hover { border-color: var(--accent); transform: translateY(-1px); }
.s-draft { border-left-color: #8b93a7 !important; }
.s-published { border-left-color: var(--ok) !important; }
.s-partial, .s-publishing { border-left-color: var(--warn) !important; }
.s-failed { border-left-color: var(--err) !important; }
.crow { display: flex; align-items: center; gap: 5px; min-width: 0; }
.ctime { font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.cdots, .mdots { display: flex; gap: 2px; margin-left: auto; flex: none; }
.ccard .dot, .mchip .dot { width: 16px; height: 16px; font-size: 8px; cursor: pointer; }
.dot.published { box-shadow: 0 0 0 2px var(--ok); }
.dot.failed { box-shadow: 0 0 0 2px var(--err); }
.cstatus { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.cstatus.published { color: var(--ok); } .cstatus.failed { color: var(--err); } .cstatus.partial, .cstatus.publishing { color: var(--warn); }
.ctext { font-size: 12px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.cthumbs { display: flex; gap: 3px; align-items: center; min-width: 0; overflow: hidden; }
.cthumbs img, .cthumbs video { width: 30px; height: 30px; object-fit: cover; border-radius: 5px; flex: none; background: var(--border); }
.cmore { font-size: 11px; color: var(--muted); padding-left: 2px; }
.fmt { flex: none; }

.cal-add { border: 1px dashed var(--border); background: none; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 6px; margin-top: auto; opacity: .55; transition: .15s; }
.wday:hover .cal-add, .mday:hover .cal-add { opacity: 1; }
.cal-add:hover { border-color: var(--accent); color: var(--accent); }

/* month */
.cal-month { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.mhead { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.mhead span { padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(118px, auto); }
.mday { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mday:nth-child(7n) { border-right: none; }
.mday.other { background: var(--panel-2); }
.mday.other .mnum b { color: var(--muted); opacity: .6; }
.mday.past:not(.today) { opacity: .75; }
.mnum { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.mnum b { font-size: 13px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.mday.today .mnum b { background: var(--accent); color: #fff; }
.mnum .cal-add { margin: 0; padding: 0 6px; font-size: 14px; border: none; opacity: 0; }
.mchip { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 3px 6px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--accent); cursor: pointer; font-size: 11.5px; }
.mchip:hover { background: var(--border); }
.mchip .mdots { margin-left: 0; order: 3; }
.mtext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.mmore { background: none; border: none; color: var(--accent); font-size: 11.5px; text-align: left; padding: 2px 6px; cursor: pointer; }

@media (max-width: 1100px) {
  .cal-week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wday { min-height: 0; }
}
@media (max-width: 700px) {
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .wday.past { display: none; }
  .mgrid { grid-auto-rows: minmax(64px, auto); }
  .mchip .mtext, .mchip .ctime { display: none; }
  .mchip { padding: 2px 3px; justify-content: center; }
  .callabel { min-width: 0; }
}

/* ===================== coverage ===================== */
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.covpill { flex: none; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; display: inline-block; }
.covpill.ok { background: rgba(60,207,122,.16); color: var(--ok); }
.covpill.mid { background: rgba(240,183,64,.18); color: var(--warn); }
.covpill.low { background: rgba(255,107,107,.16); color: var(--err); }
.covpill.none { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.cov { display: flex; flex-direction: column; gap: 8px; max-width: 1200px; }
.covrow { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.covrow:hover { border-color: var(--accent); }
.covrow.low { border-left-color: var(--err); } .covrow.mid { border-left-color: var(--warn); } .covrow.ok { border-left-color: var(--ok); }
.covhead { background: none; border: none; padding: 0 14px; cursor: default; }
.covhead:hover { border-color: transparent; }
.covinfo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.covinfo .avatar { width: 34px; height: 34px; }
.covtxt { min-width: 0; }
.covname { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.covgap { font-size: 10.5px; font-weight: 600; color: var(--warn); }
.covstrip { display: grid; grid-template-columns: repeat(28, minmax(0, 1fr)); gap: 3px; }
.covstrip i { height: 22px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); }
.covstrip i.c1 { background: rgba(108,140,255,.45); border-color: transparent; }
.covstrip i.c2 { background: var(--accent); border-color: transparent; }
.covstrip i.st { background: rgba(240,183,64,.55); }
.covstrip i.wk, .covstrip span.wk { margin-left: 4px; }
.covstrip.head span { font-size: 10px; color: var(--muted); text-align: center; }
.covstrip.head span.wk { color: var(--text); font-weight: 600; }
.ch-row[data-cov] { cursor: default; }
@media (max-width: 900px) {
  .covrow { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .covhead { display: none; }
  .covstrip i { height: 16px; }
}

.covidle { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; }
.covidle-list { display: flex; flex-wrap: wrap; gap: 8px; }
.covidle-ch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 3px; }
.covidle-ch .avatar { width: 22px; height: 22px; font-size: 9px; }
