:root {
  --bg: #0e0e10; --panel: #18181c; --line: #2a2a31; --text: #f3f3f5; --muted: #9a9aa5;
  --gold: #ffd700; --red: #ff5a5f; --green: #3ecf8e;
  --ig: #e1306c; --fb: #1877f2; --tt: #25f4ee; --yt: #ff0000;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif; }
a { color: var(--gold); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 16px; background: var(--gold); color: #111; font-weight: 700; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.muted, .hint { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 14px; min-height: 1em; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }
.login h1 { margin: 0; color: var(--gold); }
input, select, textarea { font: inherit; color: var(--text); background: #0f0f12; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }

header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: rgba(14,14,16,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 20px; } .brand span { color: var(--gold); }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav button { background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
nav button.active { color: var(--text); background: var(--panel); }
main { padding: 20px; max-width: 1200px; margin: 0 auto; }
h2 { font-size: 18px; margin: 28px 0 12px; }
h2:first-child { margin-top: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; border-top: 3px solid var(--c, var(--gold)); }
.card .net { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card .big { font-size: 30px; font-weight: 800; margin: 4px 0; }
.card .sub { font-size: 13px; color: var(--muted); }
.instagram { --c: var(--ig); } .facebook { --c: var(--fb); } .tiktok { --c: var(--tt); } .youtube { --c: var(--yt); }

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.chart svg { width: 100%; height: 160px; display: block; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.title { max-width: 380px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--line); }
.badge.instagram { background: var(--ig); } .badge.facebook { background: var(--fb); } .badge.tiktok { background: var(--tt); color: #111; } .badge.youtube { background: var(--yt); }
.badge.failed { background: var(--red); } .badge.scheduled { background: #3a3a44; } .badge.published { background: #23412f; color: var(--green); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.comment { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.comment .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment .text { margin: 8px 0; white-space: pre-wrap; }
.comment form { display: flex; gap: 8px; }
.comment form input { flex: 1; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { margin: 0; }
dialog label { display: grid; gap: 6px; font-size: 14px; }
dialog label.check { display: flex; align-items: center; gap: 8px; }
dialog label.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
fieldset > div { display: grid; gap: 6px; width: 100%; }
.preview { background: #0f0f12; border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.consent { font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.loading { color: var(--muted); padding: 20px 0; }

@media (max-width: 640px) {
  header { flex-wrap: wrap; padding: 10px 16px; }
  nav { order: 3; width: 100%; }
  main { padding: 16px; }
  .hide-mobile { display: none; }
}

/* Pages par réseau */
.app-head { display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 14px; padding: 16px 18px; }
.app-head img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--line); }
.app-head .who { flex: 1; min-width: 0; }
.app-head .who b { font-size: 20px; display: block; }
.app-head .nums { display: flex; gap: 22px; flex-wrap: wrap; }
.app-head .nums div { text-align: center; } .app-head .nums strong { display: block; font-size: 22px; }
.app-head .nums span { color: var(--muted); font-size: 12px; }
.app-card { cursor: pointer; display: flex; gap: 12px; align-items: center; }
.app-card img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.post .thumb { position: relative; aspect-ratio: 9 / 16; background: #000 center / cover no-repeat; cursor: pointer; border: 0; border-radius: 0; padding: 0; width: 100%; }
.post .thumb.square { aspect-ratio: 1; }
.post .thumb .play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: #fff; text-shadow: 0 2px 10px #000; opacity: .85; }
.post .thumb .views { position: absolute; left: 8px; bottom: 8px; font-weight: 800; font-size: 14px; color: #fff; text-shadow: 0 1px 6px #000; }
.post .body { padding: 10px; display: grid; gap: 6px; flex: 1; }
.post .date { font-size: 12px; color: var(--muted); }
.post .ttl { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.chips b { color: var(--text); }
.post .row-actions { margin-top: auto; }
.preview-dlg { width: min(420px, calc(100vw - 32px)); }
#pv-body video, #pv-body iframe { width: 100%; aspect-ratio: 9 / 16; border: 0; border-radius: 10px; background: #000; display: block; }
.pv-title { font-size: 14px; margin: 0; }
.top { display: grid; gap: 8px; }
.top a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.top img { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; background: #000; }
.top .t { flex: 1; font-size: 14px; } .top .v { font-weight: 800; }

/* Couleur par réseau : onglet et fond de page teinté */
nav button[data-tab="instagram"] { --tc: #e1306c; } nav button[data-tab="facebook"] { --tc: #1877f2; }
nav button[data-tab="tiktok"] { --tc: #25f4ee; } nav button[data-tab="youtube"] { --tc: #ff2d2d; }
nav button[data-tab="planning"], nav button[data-tab="comments"], nav button[data-tab="overview"] { --tc: #ffd700; }
nav button { border-bottom: 2px solid transparent; border-radius: 10px 10px 0 0; }
nav button:hover { color: var(--tc); }
nav button.active { color: var(--tc); border-bottom-color: var(--tc); background: color-mix(in srgb, var(--tc) 16%, transparent); }
body { transition: background .3s; }
body.theme-instagram { background: linear-gradient(160deg, rgba(131,58,180,.20), rgba(225,48,108,.16) 40%, rgba(252,175,69,.10) 80%), var(--bg); background-attachment: fixed; }
body.theme-facebook { background: linear-gradient(160deg, rgba(24,119,242,.22), rgba(24,119,242,.06) 70%), var(--bg); background-attachment: fixed; }
body.theme-tiktok { background: linear-gradient(160deg, rgba(37,244,238,.16), rgba(254,44,85,.12) 70%), var(--bg); background-attachment: fixed; }
body.theme-youtube { background: linear-gradient(160deg, rgba(255,0,0,.20), rgba(255,0,0,.05) 70%), var(--bg); background-attachment: fixed; }
body[class^="theme-"] header { background: rgba(14,14,16,.75); }
body[class^="theme-"] .card, body[class^="theme-"] .post, body[class^="theme-"] .app-head, body[class^="theme-"] table, body[class^="theme-"] .chart { background: rgba(24,24,28,.82); }
.tab-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; }
.comment.done { opacity: .55; }
.comment .likes { color: var(--muted); font-size: 12px; }
#pv-comments { display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }
#pv-comments .c { background: #0f0f12; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
#pv-comments .c b { margin-right: 6px; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.toggle input { width: auto; }

/* Nouveau post */
nav button.new-tab { color: var(--gold); }
#compose { display: grid; gap: 14px; max-width: 760px; }
#compose label { display: grid; gap: 6px; font-size: 14px; }
#compose label.check { display: flex; align-items: center; gap: 8px; }
#compose label.check input { width: auto; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.over { border-color: var(--gold); color: var(--gold); }
#c-preview { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
#c-preview video, #c-preview img { max-height: 280px; border-radius: 10px; }
.nets { gap: 10px 18px; }
.net { padding: 6px 10px; border-radius: 10px; background: #0f0f12; border-left: 3px solid var(--c, var(--gold)); }
.net.site, .net.story { --c: var(--gold); }
.variants { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
#c-progress .res { padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); margin-top: 6px; font-size: 14px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; } .bar > div { height: 100%; background: var(--gold); width: 0; transition: width .2s; }
