:root {
  --bg: #f6f6f9;
  --card: #ffffff;
  --text: #1c1c28;
  --muted: #6b6b80;
  --border: #e4e4ec;
  --primary: #d6249f;
  --primary-dark: #b01e84;
  --gradient: linear-gradient(45deg, #f9ce34, #ee2a7b 45%, #6228d7);
  --ok: #138a52;
  --ok-bg: #e5f6ee;
  --warn: #9a6200;
  --warn-bg: #fff4dc;
  --err: #c02436;
  --err-bg: #fde8ea;
  --info-bg: #eef0ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 2px 8px rgba(20, 20, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: #f0f0f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
a { color: var(--primary); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; margin: 16px 0; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-lg { font-size: 22px; margin-bottom: 4px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--gradient); font-size: 16px;
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: #fbe9f5; color: var(--primary-dark); font-weight: 600; }
.account { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.account img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); }
.dot-err { background: var(--err); }

.container { max-width: 960px; margin: 0 auto; padding: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }

/* ---------- Cards & Form ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
label .muted { font-weight: 400; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid #f3b6dd; border-color: var(--primary); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 10px 0; cursor: pointer; }
.check-lg { font-weight: 600; font-size: 15px; margin-top: 16px; }
.indent { margin-left: 26px; padding-left: 14px; border-left: 2px solid var(--border); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-group { display: grid; gap: 8px; }
.radio-card {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: start;
  margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 400;
}
.radio-card input { grid-row: span 2; margin-top: 4px; }
.radio-card:has(input:checked) { border-color: var(--primary); background: #fff6fb; }
.radio-card .muted { font-size: 13px; }
.radio-row { display: flex; gap: 24px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; }
form.card > .btn-primary { margin-top: 16px; }
.card > .row { margin-top: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 32px; }

/* ---------- Automationen ---------- */
.rules-list { display: grid; gap: 12px; }
.rule {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow);
}
.rule.disabled { opacity: 0.6; }
.rule-title { font-weight: 700; font-size: 16px; }
.rule-meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.rule-actions { display: flex; gap: 4px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: #f0f0f5; color: var(--text); margin-right: 4px;
}
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 40px; }

/* Schalter */
.switch { position: relative; width: 42px; height: 24px; margin: 0; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #cfcfda; cursor: pointer; transition: 0.15s;
}
.switch span::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: 0.15s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }

/* Beitragsauswahl */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.media-item {
  position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: #eee; aspect-ratio: 1; padding: 0;
}
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 11px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left;
}
.media-item .placeholder { display: grid; place-items: center; height: 100%; font-size: 12px; color: var(--muted); }
.media-item.selected { border-color: var(--primary); }
.media-item.selected::after {
  content: "✓"; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

/* ---------- Aktivität ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: var(--muted); }
.activity { display: grid; gap: 8px; }
.event {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
}
.event-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.event-user { font-weight: 600; color: var(--text); }
.event-text { margin: 4px 0 6px; white-space: pre-wrap; word-break: break-word; }
.event-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-err { background: var(--err-bg); color: var(--err); }
.b-muted { background: #efeff4; color: var(--muted); }
.b-info { background: var(--info-bg); color: #3a3fb0; }
.job-error { color: var(--err); font-size: 12px; width: 100%; }

/* ---------- Test ---------- */
.preview { display: grid; gap: 12px; }
.bubble { padding: 10px 14px; border-radius: 16px; background: #efeff4; white-space: pre-wrap; word-break: break-word; max-width: 520px; }
.bubble-dm { background: #3797f0; color: #fff; border-bottom-right-radius: 4px; justify-self: end; }
.bubble-btn {
  display: block; margin-top: 8px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.95);
  color: #3797f0; text-align: center; font-weight: 600;
}

/* ---------- Einstellungen ---------- */
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- Meldungen ---------- */
.error { color: var(--err); font-size: 14px; }
.error-box { background: var(--err-bg); color: var(--err); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.error-box ul { margin: 0; padding-left: 18px; }
.banner { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner a { color: inherit; font-weight: 600; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: #1c1c28; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  max-width: calc(100% - 32px);
}
.toast.toast-err { background: var(--err); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .account { margin-left: auto; }
  .container { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .rule { grid-template-columns: auto 1fr; }
  .rule-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .kv { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
}

@media (max-width: 480px) {
  .account span:not(.dot) { display: none; }
  .copy-row { flex-direction: column; }
}

details.hint { margin-top: 14px; }
details.hint summary { cursor: pointer; font-weight: 600; }
details.hint p { margin: 8px 0; }
h3.step { font-size: 14px; margin: 18px 0 6px; color: var(--primary-dark); }
