:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #17171c;
  --muted: #6b6b76;
  --border: #e3e3e8;
  --accent: #d6246e;
  --accent-text: #ffffff;
  --ok: #16794a;
  --ok-bg: #e6f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --err: #b42318;
  --err-bg: #fdecea;
  --info-bg: #eef1ff;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1b1b20;
    --text: #ececf1;
    --muted: #9a9aa6;
    --border: #2d2d35;
    --accent: #ff4f93;
    --accent-text: #16070e;
    --ok: #5fd39a;
    --ok-bg: #12301f;
    --warn: #f5c56b;
    --warn-bg: #33270f;
    --err: #ff8a80;
    --err-bg: #3a1714;
    --info-bg: #1d2140;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
.card h2 { margin: 0; }
code { font-size: .85em; background: var(--bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--bg); padding: .75rem; border-radius: 8px; overflow-x: auto; font-size: .8rem; }
small, .small { font-size: .8rem; }
.muted, small { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a.active { color: var(--text); font-weight: 600; }

.container { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: end; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.post { display: flex; gap: 1rem; padding: .75rem; }
.post video { width: 90px; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: #000; flex-shrink: 0; }
.post-body { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.post .when { font-weight: 600; margin: 0; }
.post .caption { margin: 0; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.actions { margin-top: auto; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; color: var(--muted); font-size: .85rem; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }

label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; }
label.check, label.switch { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input[type=checkbox] { width: auto; accent-color: var(--accent); transform: scale(1.15); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; margin: 0; }
legend { font-weight: 600; padding: 0 .35rem; }
.video-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.video-row video { width: 160px; aspect-ratio: 9/16; border-radius: 8px; background: #000; }
.video-row label { flex: 1; min-width: 220px; }
.cover-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.cover-row img { width: 120px; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: #000; }
.cover-row .stack { flex: 1; min-width: 220px; }
.trial-box { background: var(--info-bg); border-radius: 8px; padding: .75rem; display: flex; flex-direction: column; gap: .75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--err); }
.btn.link, button.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0 .25rem; }
.danger-text { color: var(--err) !important; }
.sticky { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; }
.danger-zone { margin-top: 2rem; }
form.inline { display: inline; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.status-scheduled { background: var(--info-bg); color: var(--text); }
.status-published { background: var(--ok-bg); color: var(--ok); }
.status-failed { background: var(--err-bg); color: var(--err); }
.status-publishing { background: var(--warn-bg); color: var(--warn); }
.badge.trial { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.auto { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--info-bg); }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }
.error-text { color: var(--err); font-size: .8rem; margin: 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); display: block; overflow-x: auto; }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table .right { text-align: right; }
.caption-cell { max-width: 320px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
tr.inactive { opacity: .55; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
details summary { cursor: pointer; }

/* Vista previa con el aspecto de un DM de Instagram (modo oscuro) */
.preview {
  display: flex; flex-direction: column; gap: .5rem; padding: 1rem;
  background: #0c0f14; color: #f5f5f5; border-radius: 20px; max-width: 360px; width: 100%;
}
.preview .stack-tight { display: flex; flex-direction: column; gap: .5rem; }
.bubble { padding: .6rem .85rem; border-radius: 18px; max-width: 85%; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; background: #262a33; }
.bubble:empty { display: none; }
.bubble.them { align-self: flex-start; }
.bubble.me { align-self: flex-end; width: 85%; }
.bubble.small { font-size: .75rem; color: #9aa0aa; background: none; padding: 0 .25rem; }
.bubble small { color: #9aa0aa; }
.fake-btn { display: block; margin-top: .6rem; background: #1b1e25; border-radius: 10px; padding: .45rem; text-align: center; font-weight: 600; }
fieldset.option { gap: .75rem; }

.login { max-width: 380px; margin: 10vh auto 0; }
.login h1 { margin-bottom: .25rem; }

.account-switch select { padding: .3rem .5rem; width: auto; }
.account-card { padding: 0; }
.account-pick { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: .35rem; width: 100%; padding: 1.25rem; }
.account-pick:hover b, .account-pick:focus-visible b { color: var(--accent); }
.add-account { margin-top: .75rem; }
