:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #15171c; --muted: #5c6370; --line: #e2e5ea; --soft: #eef1f5;
  --accent: #0a66c2; --accent-text: #ffffff; --accent-soft: #e8f1fb;
  --ok: #1a7f37; --ok-bg: #e6f4ea; --warn: #8a5a00; --warn-bg: #fff4d4; --bad: #c62828; --bad-bg: #fdecec;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014; --card: #16191f; --text: #e7e9ed; --muted: #9aa2ae; --line: #2a2f38; --soft: #1f232b;
    --accent: #4a9eed; --accent-text: #08111c; --accent-soft: #15263a;
    --ok: #4ac26b; --ok-bg: #11271a; --warn: #e3b341; --warn-bg: #2a220e; --bad: #ff7b72; --bad-bg: #2c1515;
  }
}
* { 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, sans-serif; }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
h2 .count { font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); border-radius: 99px; padding: 1px 8px; }
a { color: var(--accent); }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.run-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.conn { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.conn-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conn-head > div { min-width: 0; }
.conn-title { font-weight: 600; }
.conn-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--soft); flex: none; object-fit: cover; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.conn-detail { font-size: 13px; color: var(--muted); }
.conn-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.state { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.state.ok { color: var(--ok); } .state.warn { color: var(--warn); } .state.bad { color: var(--bad); } .state.off { color: var(--muted); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input, textarea, select { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 170px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; min-width: 0; }
.fields3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .fields3 { grid-template-columns: 1fr; } }

button, .button { font: inherit; font-size: 14px; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
button:hover, .button:hover { background: var(--soft); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.small, .button.small { font-size: 13px; padding: 4px 9px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.big { padding: 10px 18px; font-size: 15px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.chip input { width: auto; margin: 0; accent-color: var(--accent); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chip.disabled { opacity: .55; cursor: not-allowed; }

.editor { margin-top: 12px; }
.editor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.counter { font-size: 12px; color: var(--muted); }
.counter.over { color: var(--bad); font-weight: 700; }

.when { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.when input[type="datetime-local"] { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.submit-row { display: flex; justify-content: flex-end; margin-top: 14px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-time { font-weight: 600; font-size: 14px; }
.item-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; margin: 8px 0; max-height: 6.2em; overflow: hidden; position: relative; cursor: pointer; }
.item-text.open { max-height: none; cursor: auto; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.item .error { color: var(--bad); font-size: 13px; margin: 6px 0; word-break: break-word; }
.item .note { color: var(--warn); font-size: 13px; margin: 6px 0; }
.tag { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 6px; background: var(--soft); }
.tag.linkedin { background: #0a66c2; color: #fff; }
.tag.x { background: #111; color: #fff; }
@media (prefers-color-scheme: dark) { .tag.x { background: #e7e9ed; color: #111; } }
.pill { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.pill.published { background: var(--ok-bg); color: var(--ok); }
.pill.failed, .pill.missed { background: var(--bad-bg); color: var(--bad); }
.pill.scheduled, .pill.publishing { background: var(--warn-bg); color: var(--warn); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; word-break: break-word; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin-bottom: -6px; }
.login p { margin: 0; }
.login button { justify-content: center; padding: 10px; }
.gen-row { margin-top: 10px; }

/* brand + login */
.brand { display: flex; align-items: center; gap: 10px; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-weight: 900; font-size: 14px; letter-spacing: .02em; flex: none; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.login-brand .logo { width: 44px; height: 44px; font-size: 16px; }
.login label { margin: 0 0 -6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.section-head h2 { margin: 0; }
.intro { margin: 0 0 14px; }

/* automations */
.auto-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.auto { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.auto.off { opacity: .75; }
.auto-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.auto-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-line { font-size: 13px; color: var(--muted); word-break: break-word; }
.auto-line b { color: var(--text); font-weight: 600; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.editor-card { border: 2px solid var(--accent); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.editor-card h3 { margin: 0 0 4px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.editor-card textarea { min-height: 80px; }
.sched-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.day { font: inherit; font-size: 13px; font-weight: 700; width: 44px; padding: 6px 0; justify-content: center; }
.day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.times-input { width: 180px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; }
.checks input { width: auto; margin: 0; accent-color: var(--accent); }
.preview { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 640px) { .preview { grid-template-columns: 1fr; } }
.preview img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.preview pre { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 14px; margin: 4px 0 12px; }
.runs { margin-top: 14px; }
.runs summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }

/* images */
.image-box { margin-top: 14px; }
.image-box select { width: auto; }
.footer-input { flex: 1 1 220px; width: auto; min-width: 0; }
.image-chip { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.thumb { width: 96px; height: 96px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; flex: none; background: var(--soft); }
.item-body { display: flex; gap: 14px; align-items: flex-start; }
.item-body .item-text { flex: 1; min-width: 0; }
.item-body a { flex: none; }
.tag.auto { background: var(--accent-soft); color: var(--accent); }
.auto-line.error, .error { color: var(--bad); }
.auto-line.note, .note { color: var(--warn); }
