:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e2dc;
  --soft: #efede8;
  --accent: #1d1d1f;
  --accent-ink: #ffffff;
  --blue: #2563eb;
  --ok: #15803d;
  --ok-bg: #e8f5ec;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --bad: #b91c1c;
  --bad-bg: #fdeaea;
  --fb: #1877f2;
  --ig: #d62976;
  --r: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; touch-action: manipulation; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* layout */
.top {
  position: sticky; top: 0; z-index: 20; background: rgba(246,245,242,.86);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.logo { font-weight: 700; letter-spacing: -.01em; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--ink); display: inline-block; position: relative; }
.logo i::after { content: ""; position: absolute; left: 5px; top: 7px; width: 11px; height: 6px; border-left: 2.4px solid #fff; border-bottom: 2.4px solid #fff; transform: rotate(-38deg) skew(-8deg); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 550; }
.tabs a:hover { text-decoration: none; color: var(--ink); background: var(--soft); }
.tabs a.on { color: var(--ink); background: var(--panel); box-shadow: var(--shadow); }
.who { color: var(--muted); font-size: 14px; }
.who a { color: var(--muted); }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 120px; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* mobile tab bar */
.tabs.mob { display: none; }
@media (max-width: 760px) {
  .tabs.desk { display: none; }
  .tabs.mob { display: flex; }
  .li { flex-wrap: wrap; }
  .li .grow { flex: 1 1 calc(100% - 50px); }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabs a { flex: 1; text-align: center; padding: 8px 4px; font-size: 13px; }
  .tabs a.on { box-shadow: none; background: var(--soft); }
  .top-in { justify-content: space-between; }
  main { padding: 18px 16px 120px; }
  h1 { font-size: 22px; }
}

/* forms */
label.f { display: block; }
label.f > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: #b9b6ae; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
textarea { min-height: 130px; resize: vertical; }
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 16px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #000; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }

/* platform toggles */
.plats { display: flex; gap: 10px; flex-wrap: wrap; }
.plat { display: flex; align-items: center; gap: 9px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; background: #fff; min-width: 150px; }
.plat input { display: none; }
.plat .dot { width: 10px; height: 10px; border-radius: 50%; }
.plat.fb .dot { background: var(--fb); }
.plat.ig .dot { background: var(--ig); }
.plat.on { border-color: var(--ink); }
.plat.off { opacity: .45; cursor: not-allowed; }
.plat small { display: block; color: var(--muted); font-size: 12px; }

/* compose */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .compose { grid-template-columns: 1fr; } .preview-col > div { position: static !important; max-width: 340px; } }
.brandpick { position: relative; }
.brandlist { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; background: #fff; }
.brandlist button { display: flex; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; gap: 10px; align-items: center; cursor: pointer; }
.brandlist button:hover, .brandlist button.on { background: var(--soft); }
.brandlist .bname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.chosen { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.drop {
  border: 1.5px dashed #cfccc4; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fbfaf8;
}
.drop.over { border-color: var(--ink); background: #fff; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--ink); transition: width .2s; }
.thumb .x { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.thumb .mv { position: absolute; bottom: 6px; left: 6px; display: flex; gap: 4px; }
.thumb .mv button { width: 24px; height: 22px; border: 0; border-radius: 6px; background: rgba(255,255,255,.9); cursor: pointer; font-size: 12px; }
.thumb .tag { position: absolute; top: 5px; left: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.thumb.bad { outline: 2px solid var(--bad); }
.count { font-size: 12px; color: var(--muted); text-align: right; }
.count.over { color: var(--bad); }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* preview */
.phone { background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.phone .ph { display: flex; align-items: center; gap: 9px; padding: 10px 12px; font-weight: 600; font-size: 14px; }
.phone .ph .av { width: 28px; height: 28px; border-radius: 50%; }
.phone .pm { aspect-ratio: 4/5; background: var(--soft); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.phone .pm img, .phone .pm video { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.phone .pc { padding: 10px 12px 14px; font-size: 14px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.phone .pc b { margin-right: 4px; }

/* posts / calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal .dow { background: var(--soft); font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; }
.cal .day { background: #fff; min-height: 92px; padding: 6px; cursor: pointer; min-width: 0; }
.cal .day.out { background: #faf9f7; color: #b5b3ad; }
.cal .day.today .dn { background: var(--ink); color: #fff; }
.cal .day.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.cal .dn { font-size: 12px; font-weight: 600; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.chip { display: block; font-size: 11px; border-radius: 5px; padding: 2px 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--soft); }
.chip.done { background: var(--ok-bg); color: var(--ok); }
.chip.scheduled, .chip.posting { background: #e9effd; color: var(--blue); }
.chip.failed, .chip.partial { background: var(--bad-bg); color: var(--bad); }
.chip.cancelled { text-decoration: line-through; color: var(--muted); }
@media (max-width: 760px) {
  .cal .day { min-height: 54px; padding: 4px; }
  .cal .chip { font-size: 0; height: 6px; width: 6px; padding: 0; border-radius: 50%; display: inline-block; margin-right: 2px; }
  .cal .chip.more { display: none; }
}
.post { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.post:first-child { border-top: 0; }
.post .pimg { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: var(--soft); display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.post .pimg img, .post .pimg video { width: 100%; height: 100%; object-fit: cover; }
.post .cap { color: var(--muted); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 2px; }
.post .meta { font-size: 13px; color: var(--muted); }
.post .res { font-size: 13px; margin-top: 6px; display: grid; gap: 3px; }
.post .res .e { color: var(--bad); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.scheduled, .pill.posting { background: #e9effd; color: var(--blue); }
.pill.failed, .pill.partial { background: var(--bad-bg); color: var(--bad); }
.daygroup h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 4px; }
@media (max-width: 600px) { .post { grid-template-columns: 60px minmax(0,1fr); } .post .pimg { width: 60px; height: 60px; } .post .act { grid-column: 2; } }

/* brands / team tables */
.list { display: grid; gap: 0; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li .name { font-weight: 600; }
.li .grow { min-width: 0; }
.tag2 { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); }
.tag2.ig { background: #fbe7f1; color: var(--ig); }
.tag2.fb { background: #e7f0fe; color: var(--fb); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 380px; padding: 28px; }

/* toast + modal */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 18px; font-size: 14px; }
.modal dt { color: var(--muted); }
.modal dd { margin: 0; word-break: break-word; }
.code { font: 600 18px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 10px 14px; border-radius: 10px; user-select: all; }
