:root {
  --ink: #1e1b4b;
  --snow: #fff8fa;
  --candy: #ff7aa8;
  --sky: #7cc4f5;
  --sun: #ffd25e;
  --lav: #f1eeff;
  --muted: #5b5782;
  --edge: #8780c0;
  --soft: #d9d3f5;
  --danger: #b4233f;
  --font: "Bricolage Grotesque", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--snow);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--snow); }

.shell { max-width: 33rem; margin: 0 auto; padding: calc(1.25rem + var(--safe-t)) 1.25rem calc(6.5rem + var(--safe-b)); }
.shell--plain { padding-bottom: calc(2rem + var(--safe-b)); }
.stack > * + * { margin-top: 1.25rem; }
.stack-s > * + * { margin-top: 0.625rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9375rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Titres */
.brand { font-weight: 800; font-size: 1.125rem; letter-spacing: -0.01em; }
.title-xl { font-weight: 800; font-size: clamp(2.6rem, 11vw, 3.6rem); line-height: 0.98; letter-spacing: -0.035em; }
.title-l { font-weight: 800; font-size: 1.75rem; line-height: 1.05; letter-spacing: -0.025em; }
.title-m { font-weight: 700; font-size: 1.25rem; line-height: 1.15; letter-spacing: -0.015em; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0.6rem 1.4rem;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: var(--ink); color: var(--snow);
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn--candy { background: var(--candy); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Formulaires */
.field { display: block; }
.field > .label { display: block; font-weight: 700; margin-bottom: 0.375rem; }
.field > .hint { display: block; color: var(--muted); font-size: 0.9375rem; margin-top: 0.3rem; }
.input, .textarea, .select {
  width: 100%; min-height: 3rem; padding: 0.65rem 0.9rem;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 14px;
}
.textarea { min-height: 5.5rem; resize: vertical; line-height: 1.4; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.875rem; }
.row > * { min-width: 0; }
input[type="date"], input[type="time"] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
.choices { display: grid; gap: 0.625rem; border: 0; padding: 0; margin-inline: 0; min-width: 0; }
.choices legend { font-weight: 700; margin-bottom: 0.375rem; padding: 0; }
.choice {
  display: flex; gap: 0.75rem; align-items: flex-start; cursor: pointer;
  padding: 0.75rem 0.9rem; border: 2.5px solid var(--soft); border-radius: 14px; background: #fff;
}
.choice:has(input:checked) { border-color: var(--ink); background: var(--lav); }
.choice:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.choice input { margin-top: 0.3rem; accent-color: var(--ink); }
.choice b { display: block; }
.error { color: var(--danger); font-weight: 600; }
.summary { padding: 0.75rem 0.9rem; border-radius: 14px; background: var(--lav); font-weight: 600; }

/* Accueil */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; }
.welcome-doors { display: flex; gap: 0.75rem; align-items: flex-end; }
.welcome-doors .door { width: 4.5rem; flex: none; font-size: 1.5rem; }
.welcome-doors .door:nth-child(2) { width: 5.5rem; }

/* Code partagé */
.code-box {
  padding: 1.25rem; border-radius: 20px; background: var(--ink); color: var(--snow); text-align: center;
}
.code-box .btn--ghost { color: var(--snow); border-color: var(--snow); }
.code-box :focus-visible { outline-color: var(--snow); box-shadow: 0 0 0 6px var(--ink); }
.code-box .code { font-weight: 800; font-size: clamp(2rem, 10vw, 2.75rem); letter-spacing: 0.06em; line-height: 1.1; margin-top: 0.25rem; user-select: all; }

/* Portes */
.doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.75rem, 1fr)); gap: 0.875rem 0.625rem; }
.door {
  position: relative; display: grid; place-items: center; padding: 18% 0 0;
  aspect-ratio: 4 / 5; width: 100%;
  border: 2.5px solid var(--ink); border-radius: 999px 999px 12px 12px;
  background: var(--lav); color: var(--ink);
  font-weight: 800; font-size: 1.65rem; line-height: 1; letter-spacing: -0.02em;
  cursor: pointer;
}
.door::after { content: ""; position: absolute; right: 17%; top: 60%; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--ink); }
.door--locked { background: transparent; border: 2.5px dashed var(--edge); color: var(--muted); }
.door--locked::after { background: var(--edge); }
.door--ready { background: var(--sun); }
.door--ready::after { background: var(--candy); box-shadow: 0 0 0 2px var(--ink); }
.door--opened { background: var(--sky); }
.door--thanked::before {
  content: ""; position: absolute; left: 50%; bottom: 14%; width: 0.7rem; height: 0.7rem; margin-left: -0.35rem;
  background: var(--candy); border: 2px solid var(--ink); border-radius: 50%;
}
.month { margin: 1.75rem 0 0.75rem; }

.today {
  display: flex; gap: 1rem; align-items: center; padding: 1rem; border-radius: 22px;
  background: var(--sun); border: 2.5px solid var(--ink);
}
.today .door { width: 4.25rem; flex: none; background: #fff; }
.today p { font-weight: 700; line-height: 1.2; }

/* Écran d'ouverture */
.sheet {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  background: var(--ink); color: var(--snow);
  padding: calc(1rem + var(--safe-t)) 1.25rem calc(2rem + var(--safe-b));
}
.sheet-inner { max-width: 33rem; margin: 0 auto; min-height: 100%; }
.sheet-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.sheet .btn--ghost { color: var(--snow); border-color: var(--snow); }
.sheet :focus-visible { outline-color: var(--snow); box-shadow: 0 0 0 6px var(--ink); }
.stage { position: relative; perspective: 1400px; }
.reveal-hint { font-weight: 800; font-size: clamp(2rem, 8.5vw, 3rem); line-height: 1.05; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.reveal-from { color: var(--soft); margin-bottom: 0.75rem; }
.leaf { position: absolute; top: 0; bottom: 0; width: 50%; background: var(--sun); border: 2.5px solid var(--snow); display: none; backface-visibility: hidden; }
.leaf--l { left: 0; transform-origin: left center; border-radius: 999px 0 0 12px; }
.leaf--r { right: 0; transform-origin: right center; border-radius: 0 999px 12px 0; }
.leaf-number { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 5rem; color: var(--ink); z-index: 2; display: none; pointer-events: none; }
.is-opening .leaf, .is-opening .leaf-number { display: block; }
.is-opening .leaf-number { display: grid; }
.is-opening .leaf--l { animation: swing-l 0.95s 0.25s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
.is-opening .leaf--r { animation: swing-r 0.95s 0.25s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
.is-opening .leaf-number { animation: fade-out 0.3s 0.2s forwards; }
.is-opening .reveal-hint, .is-opening .reveal-from { opacity: 0; animation: fade-in 0.5s 0.85s forwards; }
@keyframes swing-l { to { transform: rotateY(-115deg); opacity: 0; } }
@keyframes swing-r { to { transform: rotateY(115deg); opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { to { opacity: 1; } }

.thanks-box { margin-top: 2rem; padding-top: 1.5rem; border-top: 2px solid rgba(255, 248, 250, 0.25); }
.sheet .input, .sheet .textarea { background: var(--snow); color: var(--ink); border-color: var(--snow); }
.sheet .muted { color: var(--soft); }
.sheet .error { color: #ffb3c4; }
.photo-preview { width: 100%; max-height: 22rem; object-fit: cover; border-radius: 16px; border: 2.5px solid var(--snow); }
.thanks-quote { font-weight: 600; font-size: 1.25rem; line-height: 1.3; }

/* À offrir */
.give-item { display: grid; grid-template-columns: 3.5rem 1fr; gap: 0.875rem; padding: 1rem 0; border-top: 2px solid var(--soft); }
.give-day { text-align: center; }
.give-day b { display: block; font-weight: 800; font-size: 2rem; line-height: 1; letter-spacing: -0.03em; }
.give-day span { color: var(--muted); font-size: 0.875rem; }
.status { font-size: 0.9375rem; color: var(--muted); display: flex; gap: 0.5rem; align-items: center; }
.status::before { content: ""; width: 0.65rem; height: 0.65rem; border-radius: 50%; border: 2px solid var(--ink); background: transparent; flex: none; }
.status--ready::before { background: var(--sun); }
.status--sent::before { background: var(--sky); }
.status--thanks::before { background: var(--candy); }
.progress { height: 0.75rem; border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.progress > i { display: block; height: 100%; background: var(--candy); }

/* Souvenirs */
.memory { padding: 1.25rem 0; border-top: 2px solid var(--soft); }
.memory .quote { font-weight: 800; font-size: 1.5rem; line-height: 1.1; letter-spacing: -0.02em; }
.memory img { margin-top: 0.75rem; border-radius: 16px; border: 2.5px solid var(--ink); max-height: 22rem; width: 100%; object-fit: cover; }

/* Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 0.25rem;
  padding: 0.5rem 0.75rem calc(0.5rem + var(--safe-b));
  background: var(--ink);
}
.tab {
  flex: 1; max-width: 8.5rem; min-height: 2.9rem; padding: 0.4rem 0.5rem;
  background: transparent; color: var(--snow); border: 0; border-radius: 999px;
  font-weight: 700; font-size: 0.9375rem; cursor: pointer;
}
.tab[aria-current="page"] { background: var(--snow); color: var(--ink); }
.tabs :focus-visible { outline-color: var(--snow); box-shadow: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + var(--safe-b)); transform: translate(-50%, 1rem);
  max-width: min(28rem, calc(100vw - 2rem)); padding: 0.75rem 1.1rem; border-radius: 14px;
  background: var(--ink); color: var(--snow); font-weight: 600; text-align: center;
  border: 2px solid var(--snow); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 40;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.notice { padding: 0.9rem 1rem; border-radius: 14px; background: var(--lav); border: 2.5px solid var(--soft); }
.settings-group { padding-top: 1.5rem; border-top: 2px solid var(--soft); }

@media (min-width: 40rem) {
  .shell { padding-top: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}

.legal-links { font-size: 0.8125rem; color: var(--muted, #5B5782); text-align: center; margin: 0.5rem 0 0; }
.legal-links a { color: inherit; text-decoration: underline; }
