:root {
  --fond: #f6f3ee;
  --carte: #ffffff;
  --texte: #1f2933;
  --doux: #66727f;
  --bord: #e3ddd3;
  --mer: #0e7490;
  --mer-clair: #e0f2f5;
  --sable: #f4c26b;
  --rouge: #c2410c;
  --vert: #15803d;
  --ombre: 0 1px 3px rgba(0, 0, 0, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #12171c;
    --carte: #1b2228;
    --texte: #e6e9ec;
    --doux: #9aa5b1;
    --bord: #2d3740;
    --mer: #38bdd8;
    --mer-clair: #15313a;
    --rouge: #fb923c;
    --vert: #4ade80;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  padding-bottom: 120px;
}
a { color: var(--mer); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 16px; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--mer); color: #fff;
}
.marque { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.barre .lien { color: #fff; }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
.attente, .vide { color: var(--doux); }
.fil { font-size: .9rem; margin-bottom: .3rem; }
.fil a { text-decoration: none; }

.carte {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  padding: 16px; margin-bottom: 16px; box-shadow: var(--ombre);
}
.carte.cliquable { cursor: pointer; display: block; text-decoration: none; color: inherit; }
.carte.cliquable:hover { border-color: var(--mer); }
.sous { color: var(--doux); font-size: .9rem; }

button, .bouton {
  font: inherit; border: 0; border-radius: 10px; cursor: pointer;
  padding: .65rem 1rem; background: var(--mer); color: #fff; font-weight: 600;
}
button:disabled { opacity: .5; cursor: default; }
button.secondaire { background: var(--mer-clair); color: var(--mer); }
button.danger { background: transparent; color: var(--rouge); border: 1px solid var(--rouge); }
button.lien { background: none; padding: 0; color: var(--mer); font-weight: 500; text-decoration: underline; }

label { display: block; font-size: .85rem; color: var(--doux); margin: .6rem 0 .2rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .6rem .7rem; border-radius: 8px;
  border: 1px solid var(--bord); background: var(--fond); color: var(--texte);
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mer); outline-offset: -1px; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grille2 { grid-template-columns: 1fr; } }
.enregistre { font-size: .8rem; color: var(--vert); min-height: 1.2em; margin-top: .4rem; }

.connexion { max-width: 380px; margin: 10vh auto; }
.erreur { color: var(--rouge); margin-top: .6rem; }

.depot {
  border: 2px dashed var(--mer); border-radius: 12px; padding: 22px 16px; text-align: center;
  background: var(--mer-clair); margin-bottom: 16px;
}
.depot.survol { background: var(--sable); }
.depot p { margin: .5rem 0 0; color: var(--doux); font-size: .9rem; }
.depot button { font-size: 1.05rem; padding: .8rem 1.3rem; }

.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .galerie { grid-template-columns: 1fr 1fr; gap: 8px; } }
.vignette {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column;
}
.vignette.etoile { border-color: var(--sable); box-shadow: 0 0 0 2px var(--sable); }
.vignette.eviter .image { opacity: .35; }
.image {
  position: relative; aspect-ratio: 1; background: var(--bord) center/cover no-repeat;
  cursor: zoom-in; display: grid; place-items: center; color: var(--doux); font-size: .8rem;
}
.badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; padding: 1px 6px; border-radius: 6px;
}
.badge.gauche { left: 6px; right: auto; }
.actions { display: flex; justify-content: space-around; border-top: 1px solid var(--bord); }
.actions button {
  flex: 1; background: none; color: var(--doux); padding: .5rem 0; border-radius: 0; font-size: 1.1rem;
}
.actions button.actif { color: var(--texte); background: var(--mer-clair); }
.commentaire { font-size: .8rem; padding: 4px 8px 6px; color: var(--doux); word-break: break-word; }
.claude { font-size: .75rem; padding: 0 8px 6px; }
.claude.oui { color: var(--vert); }
.claude.non { color: var(--rouge); }

.lot-carte { display: flex; gap: 12px; align-items: center; }
.lot-carte .bande { display: flex; gap: 4px; flex-shrink: 0; }
.lot-carte .bande span {
  width: 52px; height: 52px; border-radius: 6px; background: var(--bord) center/cover;
}
@media (max-width: 480px) { .lot-carte .bande span:nth-child(n+3) { display: none; } }
.lot-carte .infos { min-width: 0; flex: 1; }
.lot-carte .infos strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bilan { border-left: 4px solid var(--mer); }
.bilan h2::before { content: "🎬 "; }
.bilan ul { padding-left: 1.2rem; }

details.carte > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.carte > summary::-webkit-details-marker { display: none; }
details.carte > summary::after { content: " ▾"; color: var(--doux); }
details[open].carte > summary { margin-bottom: .4rem; }

.entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

#envois {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--carte); border-top: 1px solid var(--bord);
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,.1); max-height: 60vh; overflow: auto;
}
.envois-tete { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; gap: 8px; }
.jauge { height: 8px; background: var(--bord); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.jauge > div { height: 100%; width: 0; background: var(--mer); transition: width .3s; }
#envois-liste { list-style: none; padding: 0; margin: 8px 0 0; font-size: .85rem; }
#envois-liste li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--bord); }
#envois-liste li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#envois-liste .ko { color: var(--rouge); }
#envois-liste .ok { color: var(--vert); }

dialog#apercu {
  border: 0; padding: 0; background: #000; max-width: 100vw; max-height: 100vh;
  width: 100vw; height: 100vh; margin: 0;
}
dialog#apercu::backdrop { background: rgba(0,0,0,.9); }
#apercu-contenu { width: 100%; height: 100%; display: grid; place-items: center; }
#apercu-contenu img, #apercu-contenu video { max-width: 100%; max-height: 100%; }
dialog#apercu .fermer {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  background: rgba(255,255,255,.2); border-radius: 50%; width: 44px; height: 44px; padding: 0; font-size: 1.2rem;
}

.badge.haut { top: 6px; bottom: auto; left: 6px; right: auto; }
.badge.ko { background: var(--rouge); }

.editeur { width: 100%; height: 100%; display: flex; flex-direction: column; color: #eee; }
.editeur video { width: 100%; height: 42vh; object-fit: contain; background: #000; flex-shrink: 0; }
.panneau {
  flex: 1; overflow: auto; padding: 12px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 760px; width: 100%; margin: 0 auto;
}
.commandes { display: flex; gap: 8px; justify-content: center; align-items: center; margin-bottom: 10px; }
.commandes button { flex: 1; max-width: 220px; }
.commandes .temps { font: 600 1.1rem ui-monospace, monospace; min-width: 5.5em; text-align: center; }
.panneau .aide, .panneau .etat-passages { font-size: .85rem; color: #aab; text-align: center; margin: 4px 0 10px; }
.passages { list-style: none; padding: 0; margin: 0; }
.passages li { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.passages li button { flex-shrink: 0; padding: .5rem .6rem; font: 600 .85rem ui-monospace, monospace; }
.passages li input { flex: 1; min-width: 0; background: #222; color: #eee; border-color: #444; }
.panneau .couper { background: var(--sable); color: #222; max-width: none; }
dialog#apercu .fermer { z-index: 2; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.vignette .tags { padding: 6px 8px 0; gap: 4px; }
.tag {
  display: inline-block; font-size: .8rem; padding: 3px 10px; border-radius: 999px; font-weight: 500;
  background: var(--fond); color: var(--texte); border: 1px solid var(--bord);
}
.vignette .tag { font-size: .7rem; padding: 1px 7px; }
button.tag { cursor: pointer; }
.tag.on { background: var(--mer); color: #fff; border-color: var(--mer); }
.actions button { font-size: 1rem; }

dialog.fenetre-tags {
  border: 0; border-radius: 14px; padding: 16px; width: min(460px, calc(100vw - 32px));
  background: var(--carte); color: var(--texte);
}
dialog.fenetre-tags::backdrop { background: rgba(0,0,0,.5); }
.fenetre-tags h2 { margin-bottom: .2rem; }
.fenetre-tags .choisis { margin: 12px 0; min-height: 28px; }
.fenetre-tags .ajout { display: flex; gap: 8px; margin-bottom: 12px; }
.fenetre-tags .suggestions { max-height: 30vh; overflow: auto; margin-bottom: 14px; }
.fenetre-tags .commandes { justify-content: flex-end; margin: 0; }
.fenetre-tags .commandes button { flex: 0 1 auto; }

.retouche .toile { height: 55vh; display: grid; place-items: center; flex-shrink: 0; padding: 12px 12px 0; }
.retouche canvas { touch-action: none; display: block; }
.redresser { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-size: .9rem; }
.redresser input { flex: 1; padding: 0; accent-color: var(--sable); }
.redresser .angle { font: 600 .9rem ui-monospace, monospace; min-width: 3.5em; text-align: right; }
.ratios { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.ratios button { padding: .4rem .7rem; font-size: .85rem; }
.ratios button.choisi { background: var(--sable); color: #222; }
#apercu-contenu audio { width: min(500px, 90vw); }

.filtres label { margin-top: .9rem; }
.filtres label:first-child { margin-top: 0; }
.filtres select { width: auto; padding: .2rem .4rem; margin-left: 6px; font-size: .85rem; }
label.case { display: flex; gap: 8px; align-items: center; color: var(--texte); font-size: .95rem; }
label.case input { width: auto; }
.demande { margin-top: 20px; border: 2px solid var(--sable); }
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label.format {
  margin: 0; display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--bord); color: var(--texte); cursor: pointer; position: relative;
}
label.format input { position: absolute; opacity: 0; }
label.format:has(input:checked) { border-color: var(--mer); background: var(--mer-clair); }
a.bouton { display: inline-block; text-decoration: none; }
.demande-carte video { width: 100%; max-height: 70vh; background: #000; border-radius: 8px; margin-top: 10px; }
.demande-carte video.verticale { width: auto; max-width: 100%; display: block; margin-inline: auto; }
.statut { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: var(--bord); white-space: nowrap; }
.statut.prete { background: var(--vert); color: #fff; }
.statut.en_cours { background: var(--sable); color: #222; }
.statut.a_reprendre { background: var(--rouge); color: #fff; }
.retours { font-size: .9rem; padding-left: 1.2rem; }
.demande-carte details { margin-top: 8px; }
.demande-carte summary { cursor: pointer; color: var(--mer); }
#apercu-contenu > * { min-width: 0; max-width: 100%; }
.editeur, .panneau { min-width: 0; }
.retouche .toile { width: 100%; overflow: hidden; }
.creer { border: 2px solid var(--mer); }
.creer textarea { min-height: 3.2rem; margin-bottom: 10px; }
.texte-demande { font-style: italic; margin: 4px 0; }
.statut.echec { background: var(--rouge); color: #fff; }
details.demande-carte > summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 400; color: var(--texte); }
details.demande-carte > summary::after { content: "▸"; color: var(--doux); order: 3; }
details.demande-carte[open] > summary::after { content: "▾"; }
details.demande-carte .titre-demande { flex: 1; min-width: 0; display: flex; flex-direction: column; }
details.demande-carte .titre-demande strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.demande-carte[open] > summary { margin-bottom: 8px; }
