:root {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f0f0ec; --ink: #1c1c1a; --muted: #6b6b66;
  --line: #e2e2dc; --accent: #3b3bd6; --accent-ink: #ffffff; --accent-soft: #e9e9fb;
  --ok: #17794a; --ok-soft: #e1f3ea; --warn: #9a5b00; --warn-soft: #fcefd6;
  --err: #b42318; --err-soft: #fde7e4; --info: #3b3bd6; --info-soft: #e9e9fb;
  --fb: #1877f2; --ig: #d62976; --li: #0a66c2; --x: #111; --radius: 12px;
  --shadow: 0 1px 2px rgba(20,20,10,.06), 0 4px 16px rgba(20,20,10,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315; --surface: #1c1c1f; --surface-2: #25252a; --ink: #ececea; --muted: #9a9a95;
    --line: #2f2f35; --accent: #8b8bff; --accent-ink: #11112a; --accent-soft: #26264a;
    --ok: #55d19a; --ok-soft: #12301f; --warn: #f0b85a; --warn-soft: #382a0e;
    --err: #ff8a7d; --err-soft: #3a1714; --info: #8b8bff; --info-soft: #26264a;
    --x: #eee; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* Barre du haut */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand img { width: 24px; height: 24px; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* Boutons / champs */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=url], input[type=datetime-local], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
textarea { resize: vertical; min-height: 92px; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.f { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* Pastilles */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.net { display: inline-flex; width: 28px; height: 28px; border-radius: 8px; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; overflow: hidden; }
.net img { width: 100%; height: 100%; object-fit: cover; }
.net.facebook_profile, .net.facebook_page { background: var(--fb); }
.net.instagram { background: linear-gradient(135deg, #f58529, var(--ig), #515bd4); }
.net.linkedin { background: var(--li); }
.net.x { background: var(--x); color: var(--bg); }
.net.mock { background: #777; }

/* Composer */
.common { margin-bottom: 22px; }
.group { margin-top: 26px; }
.group > h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sub { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--muted); font-size: 14px; }
.target { display: grid; gap: 12px; padding: 14px; }
.target .t-head { display: flex; gap: 10px; align-items: center; }
.target .t-head label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; flex: 1; min-width: 0; }
.target input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.target.off .t-body { opacity: .55; }
.t-body { display: grid; gap: 10px; grid-template-columns: 1fr 240px; }
@media (max-width: 720px) { .t-body { grid-template-columns: 1fr; } }
.count { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.count .over { color: var(--err); font-weight: 700; }
.note { font-size: 13px; background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 8px; }
.note.info { background: var(--info-soft); color: var(--info); }

/* Média */
.slot { border: 1px dashed var(--line); border-radius: 10px; min-height: 92px; display: flex; flex-direction: column; justify-content: center; align-items: stretch; padding: 8px; background: var(--surface-2); }
.slot.drag { border-color: var(--accent); background: var(--accent-soft); }
.slot .add { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 14px 6px; text-align: center; }
.slot .add b { color: var(--accent); }
.slot img, .slot video { width: 100%; max-height: 150px; object-fit: contain; border-radius: 6px; background: #000; }
.slot .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Pied de composeur */
.dock { position: sticky; bottom: 0; margin-top: 28px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.dock .card { padding: 12px 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }

/* Liste des publications */
.post { margin-bottom: 14px; }
.post .p-head { padding: 12px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.p-target { padding: 12px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; border-bottom: 1px solid var(--line); }
.p-target:last-child { border-bottom: 0; }
.p-target .thumb { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.p-target .txt { white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: 14px; max-height: 4.6em; overflow: hidden; }
.p-target .err-msg { color: var(--err); font-size: 13px; margin-top: 4px; word-break: break-word; }
.manual-box { margin-top: 8px; padding: 10px; border-radius: 8px; background: var(--warn-soft); }
.manual-box .row { margin-top: 6px; }
@media (max-width: 600px) { .p-target { grid-template-columns: auto 1fr; } .p-target .acts { grid-column: 1 / -1; } }

/* Statistiques */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl { overflow-x: auto; }
.big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }

/* Interrupteur */
.sw { position: relative; width: 40px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.sw i { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .15s; }
.sw i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.sw input:checked + i { background: var(--accent); }
.sw input:checked + i::after { transform: translateX(18px); }
.sw input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Connexion */
.auth { max-width: 400px; margin: 12vh auto; padding: 0 16px; }
.auth .card { padding: 24px; }
.auth h1 { margin-bottom: 4px; }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.err { background: var(--err-soft); color: var(--err); }
.banner.info { background: var(--info-soft); color: var(--info); }
details.steps { margin: 8px 0 14px; font-size: 14px; color: var(--muted); }
details.steps summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.steps ol { padding-left: 20px; margin: 8px 0; }
code.k { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 460px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--err); color: #fff; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } .sw i, .sw i::after, .bar > i { transition: none; } }
