/* Contrastes vérifiés au ratio WCAG contre les deux fonds réels du site,
   --bg (#faf8f6) et --card (#ffffff). Tout ce qui porte du texte doit tenir
   4,5:1 : --ink-3 habille les consignes en 13px, c'est-à-dire précisément le
   texte qu'un invité doit pouvoir lire dans une salle mal éclairée.
     --ink-3  4,62 / 4,90
     --accent 4,74 / 5,02  (et 4,53 sur --accent-soft, et blanc dessus à 5,02)
     --warn   5,41 / 5,73  (blanc dessus)                                     */
:root {
  --bg: #faf8f6;
  --card: #ffffff;
  --ink: #191512;
  --ink-2: #5f574f;
  --ink-3: #7a6f65;
  --line: #e8e2db;
  --accent: #b4522c;
  --accent-soft: #fdf1ec;
  --ok: #2f7a52;
  --warn: #846011;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(25, 21, 18, .05), 0 8px 24px -12px rgba(25, 21, 18, .18);
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { max-width: 720px; margin: 0 auto; padding: 24px 18px 64px; }
.wrap-wide { max-width: 1100px; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 246, .92); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--serif); font-size: 18px; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }

h1 { font-family: var(--serif); font-size: clamp(28px, 6vw, 40px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 8px; }
h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px; font-weight: 600; }
p { margin: 0 0 14px; color: var(--ink-2); }
.lede { font-size: 18px; color: var(--ink-2); }
small, .small { font-size: 13px; color: var(--ink-3); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.tight { padding: 14px 16px; }

label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.check label { font-weight: 500; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; font-size: 16px; font-weight: 600; font-family: inherit;
  border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none; transition: filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.subtle { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: #fff; color: #a32c2c; border-color: #eccfcf; }
.btn.sm { padding: 8px 14px; font-size: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
}
.pill.grey { background: #f1eeea; color: var(--ink-2); }

.meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }

.notice {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; border-radius: 0 10px 10px 0; font-size: 14px; color: #7d3a1c; margin-bottom: 16px;
}

/* --- Dropzone / upload --- */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
  padding: 34px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-hero {
  padding: 54px 20px; border-color: var(--accent); background: var(--accent-soft);
  border-style: solid;
}
.drop-hero .big { font-size: 26px; margin-bottom: 6px; }
.drop-hero .ico { font-size: 46px; }
.drop-hero:active { transform: scale(.99); }
.drop .big { font-family: var(--serif); font-size: 20px; color: var(--ink); margin-bottom: 4px; }
.drop .ico { font-size: 34px; line-height: 1; margin-bottom: 10px; }
/* --- Défi photo (page invité) --- */
/* Fond sombre : c'est le seul bloc foncé de la page, l'œil tombe dessus avant
   même le bouton d'envoi — sans le remplacer, qui reste juste en dessous. */
.challenge {
  border-radius: var(--radius); padding: 18px 18px 12px;
  margin-bottom: 14px; text-align: center; background: var(--ink); color: #fff;
  box-shadow: var(--shadow);
}
.challenge-head {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}
.challenge .challenge-head { color: #f0a47f; }
.challenge-list { list-style: none; margin: 0; padding: 0; }
.challenge-list li { font-family: var(--serif); font-size: 19px; line-height: 1.35; color: var(--ink); }
.challenge .challenge-list li { color: #fff; font-size: 21px; }
/* Deux boutons de même taille, côte à côte : relever le défi (action
   principale, blanc plein) et en changer (même forme, contour). Un seul défi
   dans l'album : « Relever » prend toute la largeur. */
.challenge-actions { display: flex; gap: 10px; margin-top: 14px; }
.challenge-actions .btn { flex: 1 1 0; min-width: 0; padding: 14px 10px; font-size: 16px; line-height: 1.25; text-wrap: balance; }
/* Petits téléphones : le texte passe sur deux lignes, les deux boutons gardent la même hauteur. */
@media (max-width: 400px) { .challenge { padding: 16px 12px 14px; } .challenge-actions .btn { font-size: 15px; padding: 12px 8px; } }
.challenge-next { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }

/* Carte mise en avant dans l'espace organisateur (défis photo). */
.card-feature { border: 2px solid var(--accent); }
.card-feature h2 { color: var(--accent); }
.card-feature .copybox input { font-family: var(--sans); }
.shoot { margin-top: 12px; }
/* Bouton « Relever le défi » : clair sur fond sombre, c'est l'action principale. */
.challenge-shoot { background: #fff; color: var(--ink); }
/* Sans défis : gros bouton appareil photo, en premier. */
.shoot-main { margin: 0 0 12px; font-size: 18px; padding: 18px; }
/* Galerie : deuxième action, toujours bien visible mais moins haute. */
.drop-gallery { padding: 26px 18px; }
.drop-gallery .big { font-size: 21px; }
/* Sur un ordinateur (souris), « capture » n'a aucun effet : on masque le bouton. */
@media (hover: hover) and (pointer: fine) { .shoot { display: none; } }

.queue { list-style: none; margin: 16px 0 0; padding: 0; }
.queue li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.queue img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; flex: none; background: #eee; }
.queue .nm { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .st { font-size: 13px; font-weight: 600; color: var(--ink-3); flex: none; }
.queue .st.ok { color: var(--ok); }
.queue .st.err { color: #a32c2c; }

.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* --- Galerie --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; } }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 8px;
  background: #ece7e1; border: 0; padding: 0; cursor: pointer; display: block;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.tile:hover img { transform: scale(1.04); }
.tile .who {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff;
  font-size: 11px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Photo prise en relevant un défi : petit badge, le texte complet est dans la visionneuse. */
.tile .challenge-badge {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(25, 21, 18, .75); display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; pointer-events: none;
}
.tile.hidden-photo { outline: 2px solid var(--warn); outline-offset: -2px; }
.tile .flag {
  position: absolute; top: 5px; left: 5px; background: var(--warn); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 700;
}

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ico { font-size: 40px; margin-bottom: 10px; }

/* --- Lightbox --- */
.lb {
  position: fixed; inset: 0; background: rgba(17, 14, 12, .95); z-index: 100;
  display: none; align-items: center; justify-content: center; flex-direction: column;
}
.lb.on { display: flex; }
.lb img { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; }
.lb .lb-bar {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 14px 16px;
  display: flex; gap: 10px; align-items: center; justify-content: center;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
.lb .lb-close {
  position: absolute; top: 10px; right: 12px; background: rgba(255,255,255,.14); color: #fff;
  border: 0; width: 40px; height: 40px; border-radius: 999px; font-size: 20px; cursor: pointer;
}
.lb .nav {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12);
  color: #fff; border: 0; width: 46px; height: 46px; border-radius: 999px; font-size: 22px; cursor: pointer;
}
.lb .nav.prev { left: 8px; } .lb .nav.next { right: 8px; }
.lb .cap { color: #e8e2db; font-size: 13px; }

/* --- Admin --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

.copybox { display: flex; gap: 8px; align-items: center; }
.copybox input { font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.qrshow { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qrshow img { width: 168px; height: 168px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 22px;
  letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; max-width: 90vw; text-align: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .25s, opacity .25s, visibility .25s;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

footer.foot { text-align: center; padding: 28px 18px 40px; color: var(--ink-3); font-size: 13px; }

/* --- Affiche imprimable --- */
.poster {
  width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #191512;
  padding: 22mm 18mm; text-align: center; display: flex; flex-direction: column; justify-content: center;
}
.poster .kicker { font-size: 13pt; letter-spacing: .22em; text-transform: uppercase; color: #6f655b; margin-bottom: 8mm; }
.poster h1 { font-size: 34pt; margin-bottom: 6mm; }
.poster .sub { font-size: 15pt; color: #5f574f; margin-bottom: 12mm; }
.poster img.qr { width: 95mm; height: 95mm; margin: 0 auto 8mm; display: block; }
.poster .url { font-family: ui-monospace, Menlo, monospace; font-size: 13pt; margin-bottom: 3mm; }
.poster .codeline { font-size: 12pt; color: #5f574f; }
.poster .steps { margin-top: 12mm; font-size: 12pt; color: #5f574f; line-height: 1.7; }
/* Avec des défis, le QR rétrécit un peu pour que tout tienne sur une page A4. */
.poster:has(.poster-challenges:not([hidden])) img.qr { width: 80mm; height: 80mm; margin-bottom: 6mm; }
.poster:has(.poster-challenges:not([hidden])) .sub { margin-bottom: 8mm; }
.poster:has(.poster-challenges:not([hidden])) .steps { margin-top: 8mm; line-height: 1.5; }
.poster-challenges {
  margin: 9mm auto 0; max-width: 150mm; padding: 6mm 8mm;
  border: 0.5mm solid #b4522c; border-radius: 4mm;
}
.poster-challenges .challenge-head { font-size: 11pt; color: #b4522c; margin-bottom: 3mm; }
.poster-challenges .challenge-list li { font-size: 14pt; line-height: 1.4; margin: 1.5mm 0; }
.print-hint { max-width: 720px; margin: 20px auto; padding: 0 18px; }
@media print {
  .print-hint, header.top { display: none !important; }
  body { background: #fff; }
  .poster { box-shadow: none; margin: 0; padding: 18mm; }
  @page { size: A4; margin: 0; }
}

/* --- Accessibilité --- */
/* Un contour visible au clavier : la visionneuse et l'espace organisateur se
   parcourent entièrement à la tabulation, il faut savoir où l'on est. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.lb :focus-visible { outline-color: #fff; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 300;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* --- Pages juridiques --- */
.prose { max-width: 68ch; }
.prose h2 { margin-top: 30px; }
.prose h3 { text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--ink); margin-top: 20px; }
.prose ul { padding-left: 20px; color: var(--ink-2); margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; }
.prose th, .prose td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink); font-weight: 600; }
.prose td { color: var(--ink-2); }
.todo {
  background: #fff4d6; color: #6b4a00; padding: 1px 6px; border-radius: 4px;
  font-weight: 600; font-size: .95em;
}

/* --- Mes albums (lus dans le navigateur, jamais envoyés au serveur) --- */
.albums { list-style: none; margin: 0; padding: 0; }
.albums li {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.albums .who { flex: 1 1 200px; min-width: 0; }
.albums .nm { font-family: var(--serif); font-size: 18px; display: block; }
.albums .when { font-size: 13px; color: var(--ink-3); }
.albums .gone { opacity: .55; }

/* --- Mesures de l'album --- */
.gauge { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.gauge div { background: var(--accent-soft); border-radius: 12px; padding: 13px 14px; }
.gauge b { display: block; font-family: var(--serif); font-size: 24px; line-height: 1.15; color: var(--ink); }
.gauge span { font-size: 12px; color: var(--ink-2); }
