:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #1b2130;
  --muted: #687085;
  --line: #e3e6ee;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef0fe;
  --ok: #157a3b;
  --ok-bg: #e7f6ec;
  --warn: #9a5b06;
  --warn-bg: #fdf4e3;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --panel: #161a22;
    --panel-2: #1b2029;
    --text: #e7e9ef;
    --muted: #9aa1b2;
    --line: #2a303c;
    --brand: #8b93ff;
    --brand-ink: #0e1117;
    --brand-soft: #23264a;
    --ok: #5fd38a;
    --ok-bg: #12291b;
    --warn: #f0b45a;
    --warn-bg: #2d2311;
    --bad: #ff8a80;
    --bad-bg: #331716;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0 0 12px; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex: none; }
.brand-mark .icon { width: 16px; height: 16px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 6px 0 12px; border-top: 1px solid var(--line); }
.who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.main { padding: 28px 32px 64px; width: 100%; max-width: 1180px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.section-title { margin: 28px 0 14px; font-size: 18px; }

/* ---------- building blocks ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.tight { gap: 0 16px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); }
.stat:hover { border-color: var(--brand); }
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat-bad .num { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 26px 8px; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.07); border-color: var(--brand); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

.flash, .notice { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info, .notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice a, .flash a { color: inherit; font-weight: 700; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.s-published { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.s-failed { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.s-partial, .badge.s-publishing { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.s-scheduled { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pf { width: 24px; height: 24px; border-radius: 7px; display: inline-grid; place-items: center; color: #fff; font-size: 10.5px; font-weight: 800; flex: none; letter-spacing: -.02em; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .dropzone:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; min-height: 200px; line-height: 1.55; }
.hint { color: var(--muted); font-size: 13px; margin-top: 5px; font-weight: 400; }
.hint:empty { display: none; }
details.advanced { margin: 0 0 16px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.copy-row { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; vertical-align: middle; }
.copy-row code { min-width: 0; }
.steps { padding-left: 20px; margin: 0 0 18px; }
.steps li { margin-bottom: 8px; }
.settings { display: grid; gap: 16px; }
.settings .card { scroll-margin-top: 20px; }

/* ---------- posts ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px; color: var(--muted); }
.post { display: flex; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.post:first-of-type { border-top: 0; }
.card > .post:first-child, .card-head + .post { border-top: 0; }
.post-main { flex: 1; min-width: 0; }
.post-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.post-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.targets { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.target { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.target .pf { width: 20px; height: 20px; font-size: 9px; border-radius: 6px; }
.t-name { font-weight: 550; }
.t-status { font-size: 12px; font-weight: 700; color: var(--muted); }
.t-status.ok { color: var(--ok); }
.t-status.bad { color: var(--bad); }
.t-link { font-size: 13px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.t-link .icon { width: 13px; height: 13px; }
.t-error { flex-basis: 100%; color: var(--bad); font-size: 13px; background: var(--bad-bg); padding: 6px 10px; border-radius: 8px; overflow-wrap: anywhere; }
.post-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; width: 128px; flex: none; }
.post-actions form { margin: 0; }
.post-actions .btn { width: 100%; }

/* ---------- compose ---------- */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.compose-side { display: grid; gap: 16px; position: sticky; top: 20px; }
.counters { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter { display: inline-flex; align-items: center; gap: 6px; }
.counter .pf { width: 18px; height: 18px; font-size: 8.5px; border-radius: 5px; }
.counter.over { color: var(--bad); font-weight: 700; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 22px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; transition: border-color .15s, background .15s; }
.dropzone .icon { width: 26px; height: 26px; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.media-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.media-grid:empty { display: none; }
.media-item { position: relative; width: 104px; height: 104px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item.loading::after { content: "Uploading…"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--muted); background: var(--panel-2); }
.media-remove { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.account-pick { display: grid; gap: 8px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin: 0; font-weight: 500; }
.pick:hover { border-color: var(--muted); }
.pick:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pick input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; flex: none; }
.pick-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pick-text strong, .pick-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-text small { color: var(--muted); font-size: 12px; }
.warnings:not(:empty) { margin-top: 12px; display: grid; gap: 6px; }
.warnings div { font-size: 13px; color: var(--warn); background: var(--warn-bg); padding: 7px 10px; border-radius: 8px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 7px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--panel); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--line); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); }
.compose-buttons { display: grid; gap: 8px; }

/* ---------- accounts ---------- */
.acct-list { list-style: none; padding: 0; margin: 0; }
.acct { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.acct:first-child { border-top: 0; padding-top: 0; }
.acct .pf { width: 32px; height: 32px; font-size: 12px; border-radius: 9px; }
.acct-main { flex: 1; min-width: 0; }
.acct form { margin: 0; }
.connect-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.connect-head h3 { margin-left: 4px; }
.connect form .field:last-of-type { margin-bottom: 12px; }

/* ---------- sign in ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card .brand { padding: 0 0 18px; }
.auth-title { font-size: 22px; margin-bottom: 6px; }
.auth-card form { margin-top: 18px; }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .compose { grid-template-columns: minmax(0, 1fr); }
  .compose-side { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px; }
  .brand-name { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; gap: 0; }
  .nav a { padding: 8px 10px; }
  .nav a span { display: none; }
  .nav a .icon { width: 20px; height: 20px; }
  .side-foot { margin: 0; padding: 0; border: 0; }
  .who { display: none; }
  .main { padding: 20px 16px 48px; }
  .two-col, .three-col { grid-template-columns: minmax(0, 1fr); }
  .post { flex-direction: column; gap: 12px; }
  .post-actions { flex-direction: row; flex-wrap: wrap; width: auto; }
  .post-actions .btn { width: auto; }
}

/* ---------- sign-up and users ---------- */
.auth-alt { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.mode-options .pick-text strong, .mode-options .pick-text small { white-space: normal; }
.invite { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.invite form { margin: 0 0 8px; }
.user-list { list-style: none; padding: 0; margin: 0; }
.user { display: flex; gap: 16px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.user:first-child { border-top: 0; padding-top: 0; }
.user-off .user-name strong { color: var(--muted); }
.user-main { flex: 1; min-width: 0; }
.user-main .small { overflow-wrap: anywhere; }
.user-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 420px; }
.user-actions form { margin: 0; }
.set-password summary { list-style: none; }
.set-password summary::-webkit-details-marker { display: none; }
.set-password[open] { flex-basis: 100%; }
.set-password form { display: flex; gap: 6px; margin-top: 8px; }
.set-password input { padding: 6px 10px; font-size: 13px; }
@media (max-width: 760px) {
  .mode-options { grid-template-columns: minmax(0, 1fr); }
  .user { flex-direction: column; gap: 10px; }
  .user-actions { justify-content: flex-start; max-width: none; }
}

/* ---------- email settings ---------- */
.checks { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.checks legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.checks input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
.inline-fields { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 8px; }
.inline-form { margin-top: 12px; }

/* ---------- video, network options, AI ---------- */
.media-item.is-video img, .thumb.is-video img { filter: brightness(.85); }
.media-badge { position: absolute; left: 5px; bottom: 5px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.media-item .progress { position: absolute; inset: auto 0 0 0; background: var(--brand); color: var(--brand-ink); font-size: 11px; font-weight: 700; text-align: center; padding: 3px; z-index: 1; }
.media-item.loading .progress ~ * { display: none; }
.thumb { position: relative; display: inline-block; }
.thumb .media-badge { font-size: 9.5px; padding: 0 4px; left: 3px; bottom: 3px; }
.compose-main { display: grid; gap: 16px; min-width: 0; }
.net-options > fieldset { border: 0; padding: 0; margin: 0; }
.net-options > fieldset + fieldset { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.net-options legend { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 12px; padding: 0; }
.sub-checks { display: grid; gap: 6px; margin: 4px 0 0 24px; }
.sub-checks[hidden] { display: none; }
.ai-panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.ai-panel label { display: flex; align-items: center; gap: 6px; }
.ai-panel .icon, .ai-off .icon, h2 .icon { width: 16px; height: 16px; color: var(--brand); }
.ai-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ai-status { margin-left: 4px; }
.ai-off { display: flex; align-items: center; gap: 6px; margin: -4px 0 16px; }
.t-note { flex-basis: 100%; color: var(--muted); font-size: 13px; background: var(--panel-2); padding: 6px 10px; border-radius: 8px; }
.field.narrow { max-width: 320px; }
.connect-more { margin: 14px 0 0; }
.connect-more summary { margin-bottom: 8px; }
