:root {
  --pink: #ff4f9a;
  --pink-deep: #e0307f;
  --pink-soft: #ffd6e8;
  --pink-bg: #fff2f8;
  --lilac: #b884ff;
  --ink: #5a2347;
  --ink-soft: #9a5c82;
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 8px 24px rgba(224, 48, 127, .18);
  --font: "Fredoka", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #fff 0 1.5px, transparent 2px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 60%, #ffe9f4 0 1px, transparent 1.6px) 0 0 / 31px 31px,
    linear-gradient(160deg, #ffe3f1 0%, #ffd0e9 45%, #f1dcff 100%) fixed;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- Paillettes ---------- */
.sparkles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sparkles i {
  position: absolute; font-style: normal; color: #fff;
  text-shadow: 0 0 6px #ff9cc9, 0 0 12px #fff;
  animation: twinkle 2.8s ease-in-out infinite;
  opacity: 0;
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
  50% { opacity: .95; transform: scale(1) rotate(25deg); }
}

/* ---------- En-tête ---------- */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 6px;
  max-width: 1200px; margin: 0 auto;
}
h1 { margin: 0; line-height: 1; display: flex; flex-direction: column; }
.t-small { font-size: 15px; font-weight: 600; color: var(--ink-soft); letter-spacing: .3px; margin-left: 4px; }
.t-name {
  font-family: "Pacifico", cursive; font-weight: 400;
  font-size: clamp(38px, 9vw, 56px); line-height: 1.25;
  background: linear-gradient(100deg, #ff3d8f 0%, #ff6fb0 20%, #ffd0e6 30%, #ff6fb0 40%, #c86bff 60%, #ff3d8f 80%, #ff8fc4 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 4.5s linear infinite;
  filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 3px 6px rgba(224, 48, 127, .35));
  padding-right: 6px;
}
@keyframes shimmer { to { background-position: -250% 0; } }
.subtitle { margin: 2px 0 0 4px; font-weight: 500; color: var(--ink-soft); font-size: 15px; }

.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: var(--shadow); font-size: 20px; flex: none;
}

/* ---------- Jours ---------- */
.days {
  position: relative; z-index: 2;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px 12px; max-width: 1200px; margin: 0 auto;
  scroll-snap-type: x proximity;
}
.days::-webkit-scrollbar { display: none; }
.day {
  --c: var(--pink);
  flex: none; scroll-snap-align: center;
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid #fff; background: rgba(255, 255, 255, .7);
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 15px;
  text-transform: capitalize; color: var(--ink);
  transition: transform .15s, background .15s;
}
.day i {
  font-style: normal; font-size: 12px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--c); color: #fff; display: grid; place-items: center;
}
.day.on { background: var(--c); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 45%, transparent); transform: translateY(-1px); }
.day.on i { background: #fff; color: var(--c); }

/* ---------- Mise en page ---------- */
.layout {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: grid; gap: 16px;
}
.map-card {
  position: relative;
  border-radius: 28px; overflow: hidden;
  border: 4px solid #fff;
  box-shadow: var(--shadow), 0 0 0 2px var(--pink-soft);
}
#map { height: 46vh; min-height: 280px; background: #fde7f1; }

.pick-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 1000;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 8px 8px 16px;
  display: flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow);
}
.pick-hint button { border: 0; border-radius: 999px; padding: 6px 12px; background: #fff; color: var(--ink); font-weight: 600; }
.pick-hint[hidden] { display: none; }
body.picking #map { cursor: crosshair; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 1.4fr 1fr; align-items: start; }
  .map-card { position: sticky; top: 16px; }
  #map { height: calc(100vh - 200px); }
}

/* ---------- Épingles ---------- */
.pin-wrap { background: none; border: 0; }
.pin {
  --c: var(--pink);
  width: 40px; height: 40px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(90, 35, 71, .35);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); font-size: 19px; line-height: 1; }
.pin-n {
  position: absolute; top: -8px; right: -8px;
  min-width: 22px; height: 22px; padding: 0 4px; border-radius: 999px;
  background: #fff; color: var(--c); border: 2px solid var(--c);
  font: 700 12px/18px var(--font); text-align: center;
}

/* ---------- Liste ---------- */
.list h2 { margin: 4px 4px 10px; font-size: 22px; text-transform: none; }
.day-sep {
  --c: var(--pink);
  margin: 18px 4px 8px; font-size: 16px; color: var(--c);
  display: flex; align-items: center; gap: 8px;
}
.day-sep::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--c), transparent); }

.vcard {
  --c: var(--pink);
  width: 100%; text-align: left; position: relative;
  display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: var(--radius); background: var(--card);
  padding: 10px 14px 10px 10px; margin-bottom: 10px;
  box-shadow: 0 4px 14px rgba(224, 48, 127, .12);
  border-left: 6px solid var(--c);
  transition: transform .12s;
}
.vcard:active { transform: scale(.98); }
.vnum {
  position: absolute; top: -6px; left: -8px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--c); color: #fff;
  font-size: 13px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff;
}
.vthumb { width: 62px; height: 62px; border-radius: 16px; object-fit: cover; flex: none; }
.vthumb-emoji { display: grid; place-items: center; font-size: 30px; background: var(--pink-bg); }
.vbody { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.vbody strong { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbody small { color: var(--ink-soft); font-size: 14px; }
.vmeta { font-size: 15px; min-height: 1em; }
.badge { font-style: normal; font-size: 12px; font-weight: 600; color: var(--c); background: var(--pink-bg); border-radius: 999px; padding: 2px 8px; }

.empty {
  text-align: center; background: rgba(255, 255, 255, .75); border-radius: var(--radius);
  padding: 26px 18px; border: 2px dashed #ffb3d4;
}
.empty-emoji { font-size: 52px; animation: hop 1.6s ease-in-out infinite; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) rotate(-6deg); } }
.empty p { margin: 6px 0; }

/* ---------- Bouton + ---------- */
.fab {
  position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  border: 3px solid #fff; border-radius: 999px;
  padding: 14px 26px; font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(120deg, var(--pink) 0%, #ff7eb8 45%, var(--lilac) 100%);
  box-shadow: 0 10px 26px rgba(224, 48, 127, .45);
  overflow: hidden; white-space: nowrap;
}
.fab span { font-size: 22px; vertical-align: -2px; }
.fab::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }

/* ---------- Feuilles (dialogues) ---------- */
dialog { color: var(--ink); }
.sheet {
  border: 0; padding: 0; border-radius: 28px;
  width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 24px);
  background: #fff; box-shadow: 0 20px 60px rgba(90, 35, 71, .35);
}
.sheet::backdrop { background: rgba(255, 120, 180, .35); backdrop-filter: blur(3px); }
.sheet[open] { animation: pop .22s ease-out; }
@keyframes pop { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.sheet-in {
  padding: 18px 18px 20px;
  background:
    radial-gradient(circle at 92% 6%, #ffe0ef 0 60px, transparent 61px),
    #fff;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.close {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--pink-bg); font-size: 18px; font-weight: 700; color: var(--pink-deep);
}

.label { display: block; margin: 12px 2px 6px; font-weight: 600; font-size: 15px; color: var(--ink-soft); }
.field { display: block; }
.field input, .field select, .when select, .when input, textarea {
  width: 100%; border: 2px solid var(--pink-soft); border-radius: 16px;
  padding: 12px 14px; font-size: 17px; background: var(--pink-bg); outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, textarea:focus, .when select:focus, .when input:focus { border-color: var(--pink); background: #fff; }
.row2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }

.type-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chips label { position: relative; }
.type-chips input { position: absolute; opacity: 0; pointer-events: none; }
.type-chips span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px; background: var(--pink-bg);
  border: 2px solid var(--pink-soft); font-weight: 500; font-size: 15px; cursor: pointer;
}
.type-chips input:checked + span { background: var(--pink); border-color: var(--pink); color: #fff; }
.type-chips input:focus-visible + span { outline: 3px solid var(--lilac); }

.btn-main {
  display: block; width: 100%; margin-top: 18px;
  border: 0; border-radius: 18px; padding: 15px; font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(120deg, var(--pink), var(--lilac));
  box-shadow: 0 8px 20px rgba(224, 48, 127, .35);
}
.btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--pink-soft); background: var(--pink-bg); color: var(--ink);
  border-radius: 16px; padding: 11px 14px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-soft.danger { color: #c2185b; }
.btn-soft.wide { width: 100%; margin-top: 10px; }
.hint { color: var(--ink-soft); margin: 4px 2px 8px; }

.results { margin-top: 14px; display: grid; gap: 8px; }
.results p { margin: 4px 2px; font-weight: 500; }
.res {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  border: 2px solid var(--pink-soft); background: #fff; border-radius: 16px; padding: 11px 12px; font-size: 15px;
}
.res:hover { border-color: var(--pink); background: var(--pink-bg); }
.res.manual { background: var(--pink-bg); justify-content: center; font-weight: 600; }
.loading { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------- Fiche ---------- */
#ficheDlg { --c: var(--pink); }
.fiche-head { align-items: flex-start; }
.f-emoji {
  flex: none; width: 54px; height: 54px; border-radius: 18px; font-size: 30px;
  display: grid; place-items: center; background: var(--c); box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 40%, transparent);
}
.f-titles { flex: 1; min-width: 0; }
.f-titles h2 { font-size: 22px; line-height: 1.2; word-wrap: break-word; }
.f-titles p { margin: 3px 0 0; color: var(--ink-soft); font-size: 14px; text-transform: none; }
.approx { background: #fff6d9; border-radius: 14px; padding: 8px 12px; font-size: 14px; margin: 4px 0 8px; }
.when { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin: 4px 0; }
.when select, .when input { padding: 8px 12px; font-size: 15px; }

.block { margin-top: 14px; }
.block h3 { margin: 0 0 8px 2px; font-size: 17px; }
.block h3 small { color: var(--ink-soft); font-weight: 500; }

.thumbs { display: flex; gap: 6px; }
.thumbs button {
  flex: 1; max-width: 64px; aspect-ratio: 1; border-radius: 18px; border: 2px solid var(--pink-soft);
  background: var(--pink-bg); font-size: 26px; filter: grayscale(1); opacity: .45;
  transition: transform .15s, filter .15s, opacity .15s;
}
.thumbs button.on { filter: none; opacity: 1; background: #fff; border-color: var(--pink); transform: scale(1.06); }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button {
  aspect-ratio: 1; border-radius: 14px; border: 2px solid transparent; background: var(--pink-bg);
  font-size: 22px; padding: 0; transition: transform .12s;
}
.emoji-grid button.on { border-color: var(--pink); background: #fff; transform: scale(1.1); box-shadow: 0 4px 10px rgba(224, 48, 127, .25); }
@media (max-width: 380px) { .emoji-grid { grid-template-columns: repeat(6, 1fr); } }

textarea { resize: vertical; min-height: 100px; line-height: 1.4; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(90, 35, 71, .2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo button {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .9); color: #c2185b; font-weight: 700; font-size: 14px;
}
.add-photo {
  aspect-ratio: 1; border-radius: 16px; border: 3px dashed #ffa6cc; background: var(--pink-bg);
  display: grid; place-items: center; text-align: center; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--pink-deep);
}
.add-photo b { display: block; font-size: 28px; }

.fiche-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.fiche-actions .btn-soft { flex: 1; }

/* ---------- Visionneuse ---------- */
.viewer { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 92vh; }
.viewer::backdrop { background: rgba(40, 10, 30, .85); }
.viewer img { max-width: 96vw; max-height: 92vh; border-radius: 18px; border: 4px solid #fff; display: block; }

/* ---------- Toast & confettis ---------- */
.toast {
  position: fixed; z-index: 3000; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 500;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; z-index: 4000; pointer-events: none; font-size: 22px; left: 50%; top: 45%; animation: fly 1.1s ease-out forwards; }
@keyframes fly {
  from { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  to { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.1) rotate(var(--r)); opacity: 0; }
}

.leaflet-container { font-family: var(--font); }
.leaflet-tile-pane { filter: saturate(.8) brightness(1.04) hue-rotate(-8deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sparkles i { opacity: .6; }
}

/* ---------- Nuage / connexion / vue famille ---------- */
.sync { margin: 4px 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); min-height: 1em; }
.sync[data-state="ok"] { color: #2e9e6a; }
.sync[data-state="error"] { color: #c2185b; }

.login {
  position: fixed; inset: 0; z-index: 5000;
  display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #ffe3f1 0%, #ffd0e9 45%, #f1dcff 100%);
}
.login[hidden] { display: none; }
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 28px; padding: 26px 22px;
  box-shadow: var(--shadow); text-align: center; border: 4px solid #fff;
  outline: 2px solid var(--pink-soft);
}
.login-card form { text-align: left; }
.login-emoji { font-size: 46px; animation: hop 1.6s ease-in-out infinite; }
.login-card h2 { margin: 6px 0 4px; font-family: "Pacifico", cursive; font-weight: 400; color: var(--pink); font-size: 30px; }
.login-card > p { margin: 0 0 8px; color: var(--ink-soft); }
.login-err { min-height: 1.3em; margin: 10px 2px 0; font-weight: 600; color: #c2185b; text-align: center; }

.share-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.share-box[hidden] { display: none; }
.share-box input { min-width: 0; border: 2px solid var(--pink-soft); border-radius: 14px; padding: 10px; font-size: 13px; background: var(--pink-bg); }
.share-box .hint { grid-column: 1 / -1; font-size: 13px; margin: 0 2px; }
.btn-soft.subtle { background: #fff; color: var(--ink-soft); font-weight: 500; }

.nothing { text-align: center; color: var(--ink-soft); background: var(--pink-bg); border-radius: 16px; padding: 14px; }
.only-read { display: none; }
body.readonly .only-read { display: inline; }
body.readonly .only-edit { display: none; }
body.readonly .fab,
body.readonly #menuBtn,
body.readonly .when,
body.readonly .fiche-actions,
body.readonly .emoji-grid button:not(.on),
body.readonly .thumbs button:not(.on) { display: none; }
body.readonly .thumbs button, body.readonly .emoji-grid button { pointer-events: none; }
body.readonly .emoji-grid { display: flex; flex-wrap: wrap; }
body.readonly .emoji-grid button { width: 46px; }
body.readonly textarea { background: #fff; border-style: dashed; resize: none; }
body.readonly { padding-bottom: 24px; }
