body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background: #f0f2f5;
  color: #333;
}

#ecran-chargement, #ecran-photos, #conteneur-chargement {
  display: none;
  flex-direction: column;
  align-items: center;
}

#ecran-photos {
  position: relative;
  width: 100%;
  padding: 20px;
  box-sizing: border-box;
  min-height: 100vh;
}

.titre {
  text-align: center;
  color: #2c3e50;
  font-size: 2.5em;
  margin-top: 10px;
}

#ecran-chargement {
  box-sizing: border-box;
  padding: 0 20px;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.boite-chargement {
  background: white;
  padding: 40px 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 100%;
  max-width: 350px;
  box-sizing: border-box;
}

.boite-chargement h2 {
  margin-top: 0;
  font-size: 24px;
}

.conteneur-mdp {
  position: relative;
  width: 100%;
  margin: 15px 0;
}

.conteneur-mdp input {
  width: 100%;
  padding: 12px 45px;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  border: 2px solid #eee;
  transition: border-color 0.3s;
  text-align: center;
}

.conteneur-mdp input:focus {
  border-color: #007bff;
  outline: none;
}

#bouton-oeil {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  user-select: none;
  border-radius: 50%;
  transition: background-color 0.2s;
}

#bouton-oeil:hover {
  color: #007bff;
  background-color: rgba(0, 123, 255, 0.08);
}

.bouton-deverrouiller {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  background: #007bff;
  color: white;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bouton-deverrouiller:hover {
  background: #0056b3;
}

#erreur-chargement {
  color: #d93d33;
  margin: 20px 0 0;
  min-height: 20px;
  font-size: 14px;
  font-weight: bold;
}

#conteneur-chargement {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 40px);
  max-width: 350px;
  z-index: 1500;
}

#conteneur-photos {
  display: none;
  width: 100%;
}

#ecran-photos.pret #conteneur-photos {
  display: block;
}

.chargement {
  border: 4px solid #ddd;
  border-top-color: #007bff;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.fond-barre {
  width: 100%;
  background: #e0e0e0;
  border-radius: 10px;
  height: 12px;
  overflow: hidden;
}

#barre-chargement {
  width: 0%;
  height: 100%;
  background: #007bff;
  transition: width 0.3s ease;
}

#texte-chargement {
  color: #555;
  margin-top: 15px;
  font-weight: bold;
  font-size: 18px;
  text-align: center;
}

.date-section {
  width: 100%;
  margin: 50px 0 0;
  text-align: left;
}

.date-section:first-of-type {
  margin: 20px 0 0;
}

.date-titre {
  border-bottom: 3px solid #007bff;
  padding-bottom: 5px;
  display: inline-block;
}

.jour-galerie {
  --cols: 3;
  --gap: 20px;
  --col-width: calc((100vw - 40px - (var(--cols) - 1) * var(--gap)) / var(--cols));
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: calc(var(--col-width) * 0.75 + 42px);
  gap: var(--gap);
  width: 100%;
  grid-auto-flow: row dense;
}

.carte-photo {
  background: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
}

.carte-photo.loaded {
  animation: popIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.carte-photo:hover {
  transform: scale(1.02);
  z-index: 10;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.carte-photo img {
  width: 100%;
  flex-grow: 1;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  min-height: 0;
}

.infos {
  font-size: 0.85em;
  color: #666;
  padding: 12px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
}

.format-paysage {
  grid-column: span 1;
  grid-row: span 1;
}

.format-paysage-grand {
  grid-column: span min(2, var(--cols));
  grid-row: span min(2, var(--cols));
}

.format-portrait {
  grid-column: span 1;
  grid-row: span 2;
}

.format-panorama {
  grid-column: span 3;
  grid-row: span 1;
}

#zoom {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 3000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: zoom-out;
}

#zoom.active {
  display: flex;
  opacity: 1;
}

#zoom-image {
  max-width: 90%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

#zoom.active #zoom-image {
  transform: scale(1);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 761px) {
  .jour-galerie {
    --cols: 3;
  }
}

@media (min-width: 900px) {
  .jour-galerie {
    --cols: 4;
  }
}

@media (min-width: 1200px) {
  .jour-galerie {
    --cols: 5;
  }
}

@media (max-width: 760px) {
  .jour-galerie {
    --cols: 2;
  }

  .format-panorama {
    grid-column: span 2;
    grid-row: span 1;
  }
}

@media (max-width: 500px) {
  .titre {
    font-size: 1.8em;
  }

  .date-titre {
    font-size: 1.2em;
  }

  .jour-galerie {
    --cols: 1;
  }

  .format-paysage-grand, .format-panorama {
    grid-column: span 1;
    grid-row: span 1;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background: #121212;
    color: #e4e6eb;
  }

  .titre {
    color: #f5f6f7;
  }

  #ecran-chargement {
    background: linear-gradient(135deg, #163a4a 0%, #4a2238 100%);
  }

  .boite-chargement {
    background: #1e1e1e;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }

  .conteneur-mdp input {
    background: #2a2a2a;
    color: #f5f6f7;
    border-color: #3a3a3a;
  }

  .conteneur-mdp input:focus {
    border-color: #4da3ff;
  }

  #bouton-oeil:hover {
    color: #4da3ff;
    background-color: rgba(77, 163, 255, 0.15);
  }

  .chargement {
    border-color: #2e2e2e;
    border-top-color: #4da3ff;
  }

  .fond-barre {
    background: #2c2c2c;
  }

  #texte-chargement {
    color: #b0b3b8;
  }

  .carte-photo {
    background: #1e1e1e;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  }

  .carte-photo:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.65);
  }

  .infos {
    color: #b0b3b8;
  }
}
