:root {
  --fond: #141414;
  --carte: #222;
  --texte: #eee;
  --gris: #8a8a8a;
  --vert: #3fa66a;
  --orange: #e0a030;
  --rouge: #d0473f;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--texte); overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* --- connexion --- */
#login { display: grid; place-items: center; height: 100%; padding: 1rem; }
#login-form { display: flex; flex-direction: column; gap: .6rem; width: min(320px, 100%); }
#login-form h1 { margin: 0 0 .5rem; font-size: 1.4rem; }
#login-form input { font-size: 1.4rem; padding: .6rem; border-radius: 8px; border: 1px solid #444; background: #1e1e1e; color: var(--texte); letter-spacing: .3em; }
#login-form button { padding: .7rem; border-radius: 8px; border: 0; background: var(--vert); font-weight: 600; }
.err { color: var(--rouge); min-height: 1.2em; margin: 0; }

/* --- écran principal --- */
#main { display: flex; flex-direction: column; height: 100dvh; padding-top: env(safe-area-inset-top); }
#bars { padding: .5rem .75rem .25rem; display: grid; gap: .4rem; }
.bar-l { display: flex; justify-content: space-between; font-size: .78rem; color: var(--gris); }
.bar-l b { color: var(--texte); font-weight: 600; text-transform: capitalize; }
.bar { height: 7px; background: #333; border-radius: 4px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; transition: width .25s; }
.bar .v { background: var(--vert); }
.bar .r { background: var(--orange); }

#stage { position: relative; flex: 1; min-height: 0; margin: .25rem .5rem; }
#vide { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 1rem; color: var(--gris); }
#vide { justify-items: center; padding: 1rem; }
#vide p { margin: 0; }
#vide .vide-msg { color: var(--texte); font-size: 1.05rem; line-height: 1.4; max-width: 22rem; }
#vide .vide-date { font-size: .78rem; }
#vide button { padding: .6rem 1rem; border-radius: 8px; border: 1px solid #444; background: none; }
#vide .reprendre { border: 2px solid var(--orange); color: var(--orange); font-weight: 600; }

/* bandeau permanent : éléments en attente de retouche */
#bandeau { flex: 1; min-width: 0; padding: .2rem .5rem; font-size: .75rem; border-radius: 6px; color: var(--gris); background: #1c1c1c; }
#bandeau.on { color: var(--orange); background: rgba(224,160,48,.12); }
.ligne-b { display: flex; align-items: center; gap: .4rem; margin: 0 .75rem; }
.cloche { flex: none; padding: .1rem .35rem; font-size: .85rem; line-height: 1.2; border: 1px solid #333; border-radius: 6px; background: #1c1c1c; }
.cloche.on { border-color: var(--vert); }

/* notifications (écran « rien à valider ») */
.notifs { display: grid; gap: .5rem; justify-items: center; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid #2a2a2a; max-width: 22rem; }
.notif-etat { font-size: .82rem; line-height: 1.4; }
.notif-etat.ok { color: var(--vert); }
.notif-etat.ko { color: var(--orange); }
.notif-b { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
#vide #notif-on { border: 2px solid var(--vert); color: var(--vert); font-weight: 600; }

.card {
  position: absolute; inset: 0; background: var(--carte); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none;
  will-change: transform;
}
.card.anim { transition: transform .25s ease-out, opacity .25s; }
.card .media { position: relative; flex: 1; min-height: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.card .meta { padding: .5rem .75rem .6rem; font-size: .88rem; line-height: 1.35; max-height: 28%; overflow: auto; }
.card .meta .tag { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 4px; background: #333; margin-right: .35rem; text-transform: capitalize; }
.card .meta .tag.revoir { background: var(--orange); color: #000; }
.card .meta .tag.retouche { background: var(--vert); color: #fff; text-transform: none; }
.card .meta .lien { color: var(--gris); font-size: .75rem; word-break: break-all; }
.card .meta .prev { color: var(--orange); font-size: .8rem; }

.stamp { position: absolute; top: 1rem; padding: .2rem .6rem; border: 3px solid; border-radius: 6px; font-weight: 800; font-size: 1.4rem; opacity: 0; pointer-events: none; z-index: 3; }
.stamp.s-valide { left: 1rem; color: var(--vert); transform: rotate(-12deg); }
.stamp.s-refus { right: 1rem; color: var(--rouge); transform: rotate(12deg); }
.stamp.s-revoir { left: 50%; transform: translateX(-50%); color: var(--orange); }

/* grille carrousel : toutes les images d'un coup */
.grille { display: grid; gap: 3px; width: 100%; height: 100%; padding: 3px; align-content: center; }
.grille.n2 { grid-template-columns: 1fr 1fr; }
.grille.n3, .grille.n4 { grid-template-columns: 1fr 1fr; }
.grille.n5, .grille.n6, .grille.nx { grid-template-columns: 1fr 1fr 1fr; }
.grille img { width: 100%; height: 100%; object-fit: cover; min-height: 0; border-radius: 4px; background: #111; }
.grille.n3 img:first-child { grid-column: span 2; }
.solo { max-width: 100%; max-height: 100%; object-fit: contain; }

/* vidéo */
.card video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.vctl { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; background: linear-gradient(transparent, rgba(0,0,0,.7)); z-index: 2; }
.scrub { flex: 1; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.scrub .rail { position: relative; width: 100%; height: 4px; background: rgba(255,255,255,.3); border-radius: 2px; }
.scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #fff; border-radius: 2px; }
.son { border: 0; background: rgba(0,0,0,.5); border-radius: 50%; width: 34px; height: 34px; font-size: 1rem; }
.vinfo { position: absolute; top: .5rem; right: .5rem; z-index: 2; font-size: .8rem; background: rgba(0,0,0,.55); padding: .15rem .45rem; border-radius: 4px; pointer-events: none; }
/* préparation du proxy / mise en mémoire tampon / échec : le message laisse passer le swipe */
.vcharge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; max-width: 86%; display: flex; flex-direction: column; align-items: center; gap: .55rem; padding: .7rem .9rem; border-radius: 10px; background: rgba(0,0,0,.72); font-size: .88rem; text-align: center; pointer-events: none; }
.vcharge.err { border: 1px solid var(--rouge); }
.vcharge small { color: var(--gris); font-size: .72rem; }
.vcharge .vb { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.vcharge button { pointer-events: auto; padding: .4rem .7rem; border-radius: 8px; border: 1px solid #666; background: #2c2c2c; font-size: .8rem; }
.vcharge .spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.card.prep .vplay { display: none; }
.vplay { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3.5rem; color: rgba(255,255,255,.85); pointer-events: none; z-index: 1; text-shadow: 0 0 12px #000; }

/* boutons */
#actions { display: flex; justify-content: center; gap: 1.4rem; padding: .5rem 0 calc(.7rem + env(safe-area-inset-bottom)); }
.act { width: 64px; height: 64px; border-radius: 50%; border: 2px solid; background: none; font-size: 1.6rem; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.act small { font-size: .55rem; margin-top: .2rem; }
.act.refus { color: var(--rouge); }
.act.revoir { color: var(--orange); width: 54px; height: 54px; align-self: center; }
.act.valide { color: var(--vert); }
.act:active { transform: scale(.94); }
.act:disabled { opacity: .35; }

/* popup commentaire */
dialog { border: 0; border-radius: 14px; background: #262626; color: var(--texte); width: min(440px, 92vw); padding: 1rem; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
dialog textarea { width: 100%; font: inherit; font-size: 1rem; padding: .5rem; border-radius: 8px; border: 1px solid #444; background: #1a1a1a; color: var(--texte); resize: vertical; }
dialog .aide { font-size: .72rem; color: var(--gris); margin: .3rem 0 .6rem; }
dialog .row { display: flex; justify-content: flex-end; gap: .5rem; }
dialog .row button { padding: .5rem 1rem; border-radius: 8px; border: 1px solid #444; background: none; }
dialog #comment-ok { background: var(--vert); border-color: var(--vert); font-weight: 600; }

/* plein écran image */
#lightbox { position: fixed; inset: 0; background: #000; z-index: 50; touch-action: none; overflow: hidden; }
#lb-img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
#lb-close { position: absolute; top: calc(.6rem + env(safe-area-inset-top)); right: .6rem; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(40,40,40,.8); font-size: 1.1rem; }
#lb-pos { position: absolute; bottom: calc(.8rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: .8rem; color: var(--gris); }

/* bouton « Voir l'original » sur la fiche */
.card .meta .orig { float: right; margin-left: .5rem; font-size: .75rem; padding: .2rem .55rem; border-radius: 6px; border: 1px solid #555; background: #2c2c2c; }

/* panneau de comparaison original / montage */
#compare { position: fixed; inset: 0; z-index: 40; background: var(--fond); display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.cmp-h { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; font-size: .85rem; }
.cmp-h #cmp-titre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gris); }
.cmp-h button { border: 1px solid #444; background: none; border-radius: 8px; padding: .3rem .6rem; }
#cmp-close { width: 36px; height: 36px; border-radius: 50%; padding: 0; }
.cmp-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0 4px; }
.cmp-col { margin: 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #000; border-radius: 8px; overflow: hidden; }
.cmp-col figcaption { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); padding: .25rem .5rem; background: #1b1b1b; }
.cmp-media { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.cmp-media video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cmp-media .grille { height: auto; }
.cmp-media .lien-src { padding: 1rem; text-align: center; color: var(--gris); font-size: .85rem; word-break: break-all; }
.cmp-media .lien-src a { display: inline-block; margin-bottom: .6rem; padding: .5rem .9rem; border-radius: 8px; background: #333; color: var(--texte); text-decoration: none; }
.cmp-media .rien { color: var(--gris); font-size: .85rem; }
.cmp-f { padding: .5rem .6rem .6rem; display: grid; gap: .4rem; }
.cmp-f label { font-size: .78rem; color: var(--gris); }
.cmp-hist-t { font-size: .78rem; color: var(--gris); margin-bottom: .2rem; }
.cmp-hist ol { list-style: none; margin: 0; padding: 0; max-height: 7.5rem; overflow: auto; display: grid; gap: .3rem; }
.cmp-hist li { font-size: .82rem; line-height: 1.3; padding: .3rem .45rem; border-left: 3px solid var(--orange); background: #1c1c1c; border-radius: 0 6px 6px 0; }
.cmp-hist .h-m { display: block; font-size: .7rem; color: var(--gris); }
.cmp-hist .h-m b { color: var(--orange); font-weight: 600; }
.cmp-hist .h-t { white-space: pre-wrap; word-break: break-word; }
.cmp-f textarea { width: 100%; font: inherit; font-size: 1rem; padding: .45rem; border-radius: 8px; border: 1px solid #444; background: #1a1a1a; color: var(--texte); resize: vertical; }
.cmp-b { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.cmp-b button { padding: .55rem .3rem; border-radius: 8px; border: 2px solid; background: none; font-weight: 600; font-size: .9rem; }
.cmp-b .refus { color: var(--rouge); }
.cmp-b .revoir { color: var(--orange); }
.cmp-b .valide { color: var(--vert); }
.cmp-b button:disabled { opacity: .4; }

#toast {position: fixed; left: 50%; bottom: 6.5rem; transform: translateX(-50%); background: #333; padding: .5rem .9rem; border-radius: 8px; font-size: .88rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.on { opacity: 1; }
#toast.err { background: var(--rouge); }

.champ{display:flex;gap:.5rem;align-items:center}
.champ input{flex:1}
.champ button{padding:.6rem .8rem;background:none;border:1px solid currentColor;border-radius:.5rem;font-size:1.1rem;color:inherit}

#journal{white-space:pre-wrap;font-size:.78rem;line-height:1.35;background:#111;border:1px solid #333;border-radius:.6rem;padding:.7rem;margin-top:.7rem;max-height:45vh;overflow:auto;text-align:left}

.vide-raison{font-size:.76rem;opacity:.7;margin:.4rem 1.2rem 0;text-align:center}
