:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e4e2dc;
  --accent: #d7263d; --accent-ink: #fff; --ok: #1f8a4c; --kw: #8a5a00; --dup: #3c5a99;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: inherit; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }

.topbar { display: flex; align-items: center; gap: 28px; padding: 12px 24px; background: var(--ink); color: #fff; }
.topbar .brand { font-weight: 800; font-size: 18px; text-decoration: none; letter-spacing: -.02em; }
.topbar .brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; padding: 6px 12px; border-radius: 6px; opacity: .75; }
.topbar nav a:hover, .topbar nav a.on { opacity: 1; background: rgba(255,255,255,.12); }
.topbar .who { margin-left: auto; opacity: .75; font-size: 13px; }

.pagehead { display: flex; align-items: baseline; gap: 24px; margin-bottom: 16px; }
.pagehead h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; }
.tabs a { text-decoration: none; padding: 4px 10px; border-radius: 6px; color: var(--muted); }
.tabs a.on { background: var(--ink); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.filters select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.filters .count { margin-left: auto; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: opacity .25s, transform .25s; }
.card.gone { opacity: 0; transform: scale(.96); }
.thumb { position: relative; aspect-ratio: 9 / 16; max-height: 360px; background: #111; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img.broken { visibility: hidden; }
.thumb video { cursor: pointer; }
.net { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; background: rgba(0,0,0,.65); color: #fff; }
.net.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.meta span { color: var(--muted); white-space: nowrap; }
.film { font-weight: 600; color: var(--accent); }
.desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.b { font-size: 11px; padding: 2px 7px; border-radius: 20px; border: 1px solid currentColor; }
.b.ok { color: var(--ok); } .b.kw { color: var(--kw); } .b.dup { color: var(--dup); cursor: help; }
.actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.actions .primary { margin-left: auto; }

button, .ghost, .primary { font: inherit; border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
button { border: 0; background: var(--ink); color: #fff; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.ghost:hover { border-color: var(--ink); }
button:disabled { opacity: .5; cursor: wait; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 720px; }
.form label { display: block; margin-bottom: 16px; font-weight: 600; }
.form input { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; }
.form small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }

.login { max-width: 340px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login h1 { margin-top: 0; }
.login label { display: block; margin-bottom: 14px; font-weight: 600; }
.login input { display: block; width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login button { width: 100%; padding: 10px; }

.err { color: var(--accent); } .ok { color: var(--ok); }
.empty { color: var(--muted); padding: 24px 0; }

.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list .desc { max-width: 420px; }
.st { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--line); }
.st-scheduled { background: #dff3e6; color: var(--ok); }
.st-failed { background: #fbe1e4; color: var(--accent); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 10; }

.muted { color: var(--muted); }
.pagehead .muted a { color: var(--muted); }
.prep { display: flex; flex-direction: column; gap: 16px; }
.srcdesc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--muted); }
.srcdesc summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 12px 0; }
.steps li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.steps li small { display: block; color: var(--muted); white-space: pre-wrap; }
.steps .s-done { color: var(--ok); } .steps .s-error { color: var(--accent); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.prepform section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.prepform h2 { font-size: 16px; margin: 0 0 12px; }
.formats { display: flex; gap: 16px; flex-wrap: wrap; }
.fmt { display: flex; flex-direction: column; gap: 6px; cursor: pointer; padding: 8px; border: 2px solid transparent; border-radius: var(--radius); }
.fmt:has(input:checked) { border-color: var(--accent); background: #fff5f6; }
.fmt input { position: absolute; opacity: 0; }
.fmt video { height: 380px; max-width: 420px; background: #000; border-radius: 6px; }
.fmt span { font-weight: 600; text-align: center; }
.filmfields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.filmfields label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.filmfields input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; }
.capopts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 12px; }
.capopt { text-align: left; background: var(--bg); color: var(--ink); border: 1px solid var(--line); line-height: 1.45; padding: 10px 12px; }
.capopt:hover, .capopt.on { border-color: var(--accent); background: #fff5f6; }
.prepform textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; line-height: 1.45; }
.when { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.when input[type=datetime-local] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.formactions { display: flex; gap: 10px; }
.summary { display: flex; gap: 20px; max-width: none; }
.summary video { height: 420px; background: #000; border-radius: 6px; }
.summary .caption { white-space: pre-wrap; background: var(--bg); padding: 10px 12px; border-radius: 8px; }
.opprofiles { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }
.opprofiles legend { font-weight: 600; padding: 0 6px; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
.form label.check input { width: auto; margin: 0; display: inline; }
.st-published { background: #e3ecfb; color: var(--dup); }

main { max-width: 1440px; }
.prepform h2 small { font-weight: 400; font-size: 12px; }
.fmtgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.9fr); gap: 20px; align-items: start; }
.fmtgrid > div + div { border-left: 1px solid var(--line); padding-left: 20px; }
.fmtgrid h3 { margin: 0 0 10px; font-size: 15px; }
/* Empilement seulement sur téléphone */
@media (max-width: 900px) {
  .fmtgrid { grid-template-columns: 1fr; }
  .fmtgrid > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
}
.fmtgrid .formats { gap: 10px; }
.fmtgrid .fmt { padding: 6px; }
.fmtgrid .fmt video { height: 260px; max-width: 100%; }
.cover-src { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.cover-src input[type=url] { flex: 1 1 180px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
#cover_status { margin: 4px 0 10px; min-height: 1.2em; }
.cover-work { display: flex; flex-direction: column; gap: 12px; }
#cover_cv { width: 100%; height: auto; border-radius: 8px; cursor: crosshair; display: block; touch-action: none; user-select: none; }
.cover-fields { display: flex; flex-direction: column; gap: 10px; }
.cover-fields label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.cover-fields input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; }
.cover-out { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.cover-out a { display: flex; flex-direction: column; gap: 4px; text-decoration: none; font-size: 12px; color: var(--muted); }
.cover-out a { max-width: 100%; }
.cover-out img { max-width: 100%; max-height: 150px; height: auto; width: auto; border-radius: 6px; background: #000; }

.thumb.playable { cursor: pointer; }
.playbtn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; padding-left: 4px; pointer-events: none; transition: opacity .2s; }
.thumb.playing .playbtn { opacity: 0; }
.thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.thumb.playing .net { z-index: 2; }

button.b.dup { background: transparent; font: inherit; font-size: 11px; cursor: pointer; }
.card.open button.b.dup { background: #eef2fb; }
.versions { display: none; list-style: none; margin: 4px 0 0; padding: 0; border-top: 1px solid var(--line); }
.card.open .versions { display: block; }
.versions li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.versions li.cur { background: #fff5f6; margin: 0 -12px; padding: 8px 12px; }
.vmeta { display: flex; gap: 6px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.vnet { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: #111; color: #fff; }
.vnet.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.vdesc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.vact { display: flex; gap: 6px; }
.vact .ghost, .vact .primary { padding: 4px 9px; font-size: 12px; }
.vact .primary { margin-left: auto; }

/* ===== Planning ===== */
.pday { font-size: 16px; margin: 26px 0 10px; display: flex; gap: 8px; align-items: baseline; }
.pday .muted { font-size: 13px; font-weight: 400; }
.pday.small { font-size: 14px; margin: 14px 0 8px; color: var(--muted); }
.pday.pdone { border-top: 1px solid var(--line); padding-top: 20px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.plist.faded .prow { opacity: .75; }
.prow { display: grid; grid-template-columns: 54px 110px minmax(0, 1fr) auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 8px 8px; }
.pthumb { display: block; width: 54px; height: 96px; border-radius: 6px; overflow: hidden; background: #111; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ptime { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ptime strong { font-size: 18px; letter-spacing: -.01em; }
.pmain { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ptitle { font-weight: 700; font-size: 15px; text-decoration: none; }
.ptitle:hover { color: var(--accent); }
.pmain .muted { font-size: 12px; }
.pcap { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdl { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 360px; }
.dl { font-size: 12px; text-decoration: none; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
.dl:hover { border-color: var(--ink); }
.dl-video { background: var(--ink); color: #fff; border-color: var(--ink); }
.dl-video:hover { background: #000; }
.st-ready { background: #fff1d6; color: var(--kw); }
.st-processing { background: #eef2fb; color: var(--dup); }
@media (max-width: 800px) {
  .prow { grid-template-columns: 54px minmax(0, 1fr); }
  .ptime { flex-direction: row; align-items: center; }
  .pdl { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}

/* Récapitulatif du mois (replié par défaut) */
.pcal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
.pcal summary { cursor: pointer; display: flex; gap: 6px; align-items: baseline; list-style: none; }
.pcal summary::-webkit-details-marker { display: none; }
.pcal summary::before { content: '▸'; color: var(--muted); width: 12px; }
.pcal[open] summary::before { content: '▾'; }
.pcal summary .muted { font-size: 13px; }
.pcal-body { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.pcal-nav { text-decoration: none; font-size: 20px; color: var(--muted); padding: 0 4px; }
.pcal-nav:hover { color: var(--ink); }
.pcal-days { display: flex; gap: 0; flex: 1; overflow-x: auto; padding-bottom: 2px; }
.pcal-day { flex: 1 0 30px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0 5px; text-decoration: none; border: 1px solid transparent; }
.pcal-day.wk-a { background: #ecebe6; }
.pcal-day.wk-b { background: #fff; }
.pcal-day.mon { margin-left: 5px; }
.pcal-day:hover { background: #dedcd5; }
.pcal-day .wd { font-size: 10px; color: var(--muted); }
.pcal-day .dn { font-size: 13px; font-weight: 600; }
.pcal-day.past { opacity: .5; }
.pcal-day.today { border-color: var(--accent); border-radius: 4px; }
.pcal-day .dots { display: flex; gap: 2px; min-height: 7px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ccc; }
.dot-scheduled { background: var(--ok); }
.dot-ready { background: #e0a100; }
.dot-published { background: var(--dup); }
.dot-failed { background: var(--accent); }
.pcal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; margin-top: 8px; }
.pcal-legend .dot { vertical-align: 0; margin-right: 3px; }
.pday { scroll-margin-top: 12px; }

/* ===== Ajouter ===== */
.addbtn { margin-left: auto; font-size: 13px; }
.addform { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.addform .panel { max-width: none; }
.addform h2 { font-size: 16px; margin: 0 0 12px; }
.addform h2 small { font-weight: 400; font-size: 12px; }
.addsrc { display: flex; gap: 20px; margin-bottom: 12px; }
.srcopt { display: flex; gap: 6px; align-items: center; cursor: pointer; font-weight: 600; }
.mode-url, .mode-file { display: flex; flex-direction: column; gap: 6px; }
.mode-url[hidden], .mode-file[hidden], .progress[hidden] { display: none; }
.addform input[type=url], .addform input:not([type]), .addform input[type=date], .addform textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; width: 100%; }
.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.addgrid label, .addform label.full { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.progress { position: relative; height: 22px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.progress .bar { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
#add_status { align-self: center; }
