:root {
  --bg1: #eef2ff;
  --bg2: #fdf2f8;
  --card: #ffffff;
  --ink: #1f2433;
  --muted: #8a90a2;
  --accent: #6366f1;
  --accent-d: #4f46e5;
  --radius: 22px;
  --shadow: 0 18px 50px -12px rgba(40, 44, 80, .28);
  --shadow-sm: 0 6px 18px -6px rgba(40, 44, 80, .22);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 18px calc(56px + env(safe-area-inset-bottom));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---- Cartes ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.title {
  margin: 8px 0 4px;
  text-align: center;
}
.title h1 {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2rem);
  letter-spacing: -.02em;
}

.phrase {
  font-size: clamp(1.2rem, 5vw, 1.4rem);
  line-height: 1.5;
  font-weight: 600;
  text-align: center;
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.free-text {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: clamp(1rem, 4vw, 1.05rem);
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ---- Galerie photos ---- */
.gallery {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.gallery.two { grid-template-columns: 1fr 1fr; }
.gallery.three { grid-template-columns: 1fr 1fr 1fr; }
.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  display: block;
  aspect-ratio: 4 / 3;
}
.gallery.one img { aspect-ratio: auto; max-height: 480px; object-fit: contain; background: #f6f7fb; }

@media (max-width: 560px) {
  .gallery.two, .gallery.three { grid-template-columns: 1fr; gap: 12px; }
  .gallery img { aspect-ratio: 3 / 2; }
  .gallery.one img { max-height: 70vh; }
  .card { padding: 22px 20px; border-radius: 18px; }
  .title h1 { font-size: 1.55rem; }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

/* ---- Admin ---- */
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-head h1 { font-size: 1.3rem; margin: 0; }
.badge {
  font-size: .8rem;
  color: var(--muted);
  background: #f1f3fa;
  padding: 4px 10px;
  border-radius: 999px;
}

label.field { display: block; margin-bottom: 22px; }
label.field > span {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: .95rem;
}
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }

input[type=text], textarea {
  width: 100%;
  border: 1.5px solid #e4e7f0;
  border-radius: 14px;
  padding: 13px 15px;
  font: inherit;
  color: var(--ink);
  background: #fbfbfe;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}
textarea { resize: vertical; min-height: 120px; }
::placeholder { color: #b7bccb; }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.photo-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  aspect-ratio: 1;
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.del-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(20, 22, 35, .72);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.del-x:hover, .del-x:active { background: #ef4444; }

.photos-grid:empty { display: none; }

.file-drop {
  border: 1.5px dashed #cdd2e4;
  border-radius: 14px;
  padding: 16px;
  background: #fbfbfe;
  font-size: .9rem;
  color: var(--muted);
}
.file-drop input { margin-top: 8px; }

button, .btn {
  font: inherit;
  font-weight: 600;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 13px 22px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .08s, background .15s;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-d); }
button:active { transform: translateY(1px); }
.btn-ghost {
  background: #eef0f7;
  color: var(--ink);
  box-shadow: none;
}
.btn-ghost:hover { background: #e2e5f0; }

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

/* ---- Flash ---- */
.flash {
  border-radius: 14px;
  padding: 12px 16px;
  font-size: .92rem;
  font-weight: 500;
}
.flash.ok { background: #e7f8ef; color: #15784a; }
.flash.error { background: #fdecec; color: #c0392b; }

/* ---- Overlay enregistrement ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 36, 51, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay[hidden] { display: none; }
.overlay-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px 34px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 80vw;
}
.overlay-box p { margin: 16px 0 0; font-weight: 600; }
.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border: 4px solid #e4e7f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login ---- */
.login-card { max-width: 380px; margin: 14vh auto 0; }
.login-card h1 { text-align: center; font-size: 1.4rem; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.login-card button { width: 100%; }
