/* Livrés à l'aveugle — papier kraft, ruban doré, papier cadeau rouge */
:root {
  --fond: #f7f1e6;
  --surface: #fffdf8;
  --encre: #2b2420;
  --encre-douce: #6d625a;
  --trait: #e3d8c6;
  --accent: #b5453a;
  --accent-fonce: #8f3027;
  --accent-texte: #ffffff;
  --ruban: #e2b45c;
  --ok: #3f7d4e;
  --ok-fond: #e5f1e5;
  --attente: #9a6a12;
  --attente-fond: #f8edd3;
  --erreur: #a8322a;
  --erreur-fond: #fbe4e1;
  --kraft: #caa77a;
  --kraft-fonce: #b38f62;
  --ombre: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1d1916;
    --surface: #272220;
    --encre: #f1e9de;
    --encre-douce: #b8aca0;
    --trait: #3d3530;
    --accent: #d8665a;
    --accent-fonce: #e98579;
    --accent-texte: #1d1916;
    --ruban: #e2b45c;
    --ok: #8fcf9c;
    --ok-fond: #22362a;
    --attente: #e8c06c;
    --attente-fond: #3a2f1a;
    --erreur: #f0948a;
    --erreur-fond: #3d2421;
    --kraft: #7d6446;
    --kraft-fonce: #6a533a;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 17px/1.55 var(--sans);
}
a { color: var(--accent-fonce); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: .2em 0 .4em; }
h2 { font-size: 1.3rem; margin: 0 0 .5em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------ Structure */
.entete { padding: 18px 16px 0; max-width: 760px; margin: 0 auto; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--encre);
        font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.logo em { color: var(--accent); font-style: italic; }
.logo-livre { width: 30px; height: 36px; flex: none; }
.logo-paquet-ancien { width: 26px; height: 22px; border-radius: 4px; background:
  linear-gradient(90deg, transparent 42%, var(--ruban) 42% 58%, transparent 58%),
  linear-gradient(0deg, transparent 40%, var(--ruban) 40% 58%, transparent 58%), var(--accent); }
.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.pied { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; color: var(--encre-douce); font-size: .85rem;
        border-top: 1px solid var(--trait); }
.pied a { color: inherit; }

.surtitre { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 600;
            color: var(--accent); margin: 24px 0 0; }
.chapo { font-size: 1.1rem; color: var(--encre-douce); max-width: 60ch; }
.aide { color: var(--encre-douce); font-size: .9rem; margin: .3em 0 .8em; }
.label { font-weight: 600; margin: 1em 0 .4em; }
.facultatif { font-weight: 400; color: var(--encre-douce); font-size: .9em; }

.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: 14px; padding: 20px;
         margin: 16px 0; box-shadow: var(--ombre); }
.carte > :last-child { margin-bottom: 0; }

/* ------------------------------------------------ Boutons */
.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-texte); font: 600 1rem var(--sans); text-decoration: none; cursor: pointer; }
.bouton:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.bouton:disabled { opacity: .45; cursor: not-allowed; }
.bouton-grand { min-height: 52px; padding: 12px 26px; font-size: 1.08rem; margin-top: 8px; }
.bouton-discret { background: transparent; color: var(--accent-fonce); border-color: var(--trait); }
.bouton-discret:hover { background: var(--fond); border-color: var(--accent); color: var(--accent-fonce); }
.bouton-lien { background: none; border: 0; padding: 6px 0; color: var(--accent-fonce); cursor: pointer;
  font: inherit; text-decoration: underline; }
.danger { color: var(--erreur); }
.bouton.danger { background: var(--erreur); border-color: var(--erreur); color: var(--accent-texte); }
.bouton-icone { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--trait);
  background: transparent; color: var(--encre-douce); font-size: 1.3rem; cursor: pointer; }
.bouton-icone:hover { color: var(--erreur); border-color: var(--erreur); }
:focus-visible { outline: 3px solid var(--ruban); outline-offset: 2px; }

/* ------------------------------------------------ Formulaires */
.formulaire fieldset { border: 1px solid var(--trait); background: var(--surface); border-radius: 14px;
  padding: 18px 20px 20px; margin: 0 0 18px; box-shadow: var(--ombre); min-width: 0; }
.formulaire legend { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; padding: 0 6px; }
label { display: block; font-weight: 600; margin: .9em 0 .35em; }
input, select, textarea { width: 100%; font: 1rem var(--sans); color: var(--encre); background: var(--fond);
  border: 1px solid var(--trait); border-radius: 10px; padding: 11px 12px; min-height: 46px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.case { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: .55em 0; cursor: pointer; }
.case input { width: 20px; height: 20px; min-height: 0; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.erreur { color: var(--erreur); font-size: .92rem; font-weight: 600; margin: .35em 0; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .deux-colonnes { grid-template-columns: 1fr; } }
.ligne-proche { display: flex; gap: 8px; margin-bottom: 8px; }
.piege { position: absolute; left: -9999px; }
.accroches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.puce { border: 1px dashed var(--kraft-fonce); background: transparent; color: var(--encre); border-radius: 999px;
  padding: 7px 14px; font: .9rem var(--sans); cursor: pointer; text-align: left; }
.puce:hover { background: var(--fond); border-style: solid; }
.puces { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.puce-statique { cursor: default; border-style: solid; }
.ligne-form { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.ligne-form input { flex: 1 1 180px; width: auto; }

.alerte { border-radius: 12px; padding: 14px 16px; margin: 16px 0; background: var(--attente-fond);
  color: var(--encre); border: 1px solid color-mix(in srgb, var(--attente) 35%, transparent); }
.alerte-ok { background: var(--ok-fond); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alerte-erreur { background: var(--erreur-fond); border-color: color-mix(in srgb, var(--erreur) 35%, transparent); }

/* ------------------------------------------------ Accueil */
.hero { display: grid; gap: 8px; align-items: center; }
.hero-image { width: 100%; max-width: 420px; height: auto; justify-self: center; }
@media (min-width: 700px) { .hero { grid-template-columns: 1.15fr 1fr; gap: 24px; } .hero h1 { font-size: 2.3rem; } }
.etape-image { display: block; width: 100%; height: 150px; object-fit: contain; margin: -4px 0 10px; }
.hero { padding: 24px 0 8px; }
.hero h1 span { color: var(--accent); font-style: italic; font-weight: 500; }
.etapes ol { list-style: none; padding: 0; margin: 32px 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.etapes li { background: var(--surface); border: 1px solid var(--trait); border-radius: 14px; padding: 18px;
  box-shadow: var(--ombre); }
.etapes h2 { font-size: 1.1rem; margin: 10px 0 6px; }
.etapes p { margin: 0; color: var(--encre-douce); font-size: .95rem; }
.etape-num { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ruban); color: #2b2420; font-weight: 700; font-family: var(--serif); }
.encart { border-left: 4px solid var(--ruban); padding: 4px 0 4px 16px; margin: 28px 0; }
.encart p { color: var(--encre-douce); margin: 0; }
.encart-pile { display: flex; gap: 20px; align-items: center; }
.encart-image { width: 96px; height: auto; flex: none; }
@media (max-width: 480px) { .encart-image { width: 64px; } }
.faq details { border-bottom: 1px solid var(--trait); padding: 12px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { color: var(--encre-douce); margin: .5em 0 0; }

/* ------------------------------------------------ Tableau de bord */
.copie { display: flex; gap: 8px; margin: 6px 0 10px; }
.copie input { font-family: var(--mono); font-size: .85rem; color: var(--encre-douce); min-width: 0; }
.copie .bouton { flex: none; }
.cle { border-color: color-mix(in srgb, var(--ruban) 60%, var(--trait)); }
.gros-chiffre { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; margin: 0; line-height: 1.1; }
.gros-chiffre span { font-size: 1rem; font-family: var(--sans); color: var(--encre-douce); font-weight: 400; }
.jauge { height: 10px; border-radius: 99px; background: var(--fond); border: 1px solid var(--trait);
  overflow: hidden; margin: 10px 0 12px; }
.jauge span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.liste-proches { list-style: none; padding: 0; margin: 0; }
.proche { border-top: 1px solid var(--trait); padding: 12px 0; }
.proche:first-child { border-top: 0; }
.proche-tete { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.badge { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--fond);
  color: var(--encre-douce); white-space: nowrap; }
.badge-ok { background: var(--ok-fond); color: var(--ok); }
.badge-attente { background: var(--attente-fond); color: var(--attente); }
.actions-proche summary { cursor: pointer; color: var(--encre-douce); font-size: .9rem; }
.ajout { margin-top: 14px; }
.profil { margin: 0; padding: 12px 16px; border-left: 3px solid var(--kraft); background: var(--fond);
  border-radius: 0 10px 10px 0; font-family: var(--serif); font-size: 1.05rem; }
.zone-danger summary { cursor: pointer; color: var(--erreur); font-weight: 600; }

/* Onglets du tableau de bord */
.onglets { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 6px; margin: 20px 0 4px;
  position: sticky; top: 0; z-index: 5; background: var(--fond); padding: 8px 0; }
.onglet { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px;
  border: 1px solid var(--trait); border-radius: 12px; background: var(--surface); color: var(--encre);
  text-decoration: none; min-width: 0; }
.onglet-num { font: 700 .75rem var(--sans); color: var(--encre-douce); }
.onglet-nom { font: 600 .98rem var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.onglet-etat { font-size: .78rem; color: var(--encre-douce); }
.onglet.etape-faite .onglet-num::after { content: ' ✓'; color: var(--ok); }
.onglet.etape-en-cours { border-color: var(--ruban); }
.onglet.actif { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.onglet.actif .onglet-num { color: var(--accent); }
.onglet-reglages { align-items: center; justify-content: center; }
.onglet-reglages .onglet-num { font-size: 1.2rem; }
.onglet-reglages .onglet-nom { display: none; }
@media (max-width: 520px) {
  .onglet { padding: 8px; }
  .onglet-nom { font-size: .85rem; }
}
body:not(.avec-onglets) .panneau { border-top: 1px dashed var(--trait); margin-top: 18px; }
.carte.vide { text-align: center; color: var(--encre-douce); }
.resume-carte { cursor: pointer; font: 600 1.1rem var(--serif); }
details.carte[open] .resume-carte { margin-bottom: 8px; }
.infos { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.infos dt { color: var(--encre-douce); }
.infos dd { margin: 0; }

/* Gestion */
.gestion-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.gestion-liste { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.gestion-ligne { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; padding: 12px 14px; }
.gestion-ligne .case { margin: 0; flex: 1 1 260px; }
.gestion-ligne small { color: var(--encre-douce); display: inline-block; margin-top: 4px; }

/* ------------------------------------------------ Recommandation */
.recherche { display: flex; gap: 8px; }
.recherche input { min-width: 0; }
.resultats { display: grid; gap: 8px; margin: 8px 0 4px; }
.resultat { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; padding: 8px;
  background: var(--fond); border: 1px solid var(--trait); border-radius: 10px; cursor: pointer;
  color: var(--encre); font: inherit; }
.resultat:hover, .resultat[aria-pressed="true"] { border-color: var(--accent); }
.resultat img, .resultat .vignette-vide { width: 44px; height: 64px; object-fit: cover; border-radius: 4px;
  flex: none; background: var(--kraft); }
.resultat strong { display: block; font-family: var(--serif); }
.resultat small { color: var(--encre-douce); }
.resultats .info { color: var(--encre-douce); font-size: .92rem; margin: 4px 0; }
.livre-choisi { display: flex; gap: 16px; align-items: flex-start; margin-top: 8px; }
.livre-choisi img { width: 92px; border-radius: 6px; box-shadow: var(--ombre); margin-top: 1.2em; flex: none; }
.champs-livre { flex: 1; min-width: 0; }
.merci, .attente { text-align: center; padding: 24px 0; }
.merci .chapo, .attente .chapo { margin-left: auto; margin-right: auto; }
.paquet-merci { width: 96px; height: 80px; margin: 10px auto 18px; border-radius: 8px; position: relative; background:
  linear-gradient(90deg, transparent 43%, var(--ruban) 43% 57%, transparent 57%),
  linear-gradient(0deg, transparent 42%, var(--ruban) 42% 58%, transparent 58%), var(--accent);
  animation: balancer 3s ease-in-out infinite; }
@keyframes balancer { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

/* ------------------------------------------------ Libraire */
.actions-libraire { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 20px; }
.commande { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.commande-ligne { background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; padding: 16px;
  break-inside: avoid; }
.commande dl { display: grid; grid-template-columns: 80px 1fr; gap: 4px 12px; margin: 10px 0 0; }
.commande dt { color: var(--encre-douce); }
.commande dd { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); }
.etiquette { display: inline-block; margin: 0; padding: 6px 12px; background: var(--surface); color: var(--encre);
  border: 1px dashed var(--kraft-fonce); border-radius: 6px; font-family: var(--serif); font-weight: 600; }
.etiquette span { font-family: var(--sans); font-weight: 400; color: var(--encre-douce); margin-left: 6px; }

.garde-fou { text-align: center; }
.garde-fou .actions-libraire { justify-content: center; }

/* ------------------------------------------------ Révélation */
.grille { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 16px;
  grid-template-columns: 1fr; }
@media (min-width: 600px) { .grille { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
.case-cal { border-radius: 14px; min-height: 230px; position: relative; overflow: hidden; }
.emballage { height: 100%; min-height: 230px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 20px; text-align: center; position: relative; }
.case-prete .emballage { background:
  repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 10px, transparent 10px 20px), var(--accent); }
.case-fermee .emballage { background:
  repeating-linear-gradient(45deg, rgba(0,0,0,.04) 0 10px, transparent 10px 20px), var(--kraft); }
.ruban { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(90deg, transparent calc(50% - 9px), var(--ruban) calc(50% - 9px) calc(50% + 9px), transparent calc(50% + 9px)),
  linear-gradient(0deg, transparent calc(50% - 9px), var(--ruban) calc(50% - 9px) calc(50% + 9px), transparent calc(50% + 9px));
  opacity: .9; }
.emballage .etiquette, .emballage form, .emballage .verrou { position: relative; }
.emballage .etiquette { display: flex; flex-direction: column; box-shadow: var(--ombre); transform: rotate(-2deg); }
.emballage .etiquette span { margin: 2px 0 0; }
.emballage .bouton { background: var(--surface); color: var(--accent-fonce); border-color: var(--surface); }
.verrou { margin: 0; background: rgba(255,255,255,.85); color: #2b2420; padding: 4px 12px; border-radius: 99px;
  font-size: .85rem; font-weight: 600; }
.case-ouverte { background: var(--surface); border: 1px solid var(--trait); box-shadow: var(--ombre); padding: 16px; }
.case-contenu { display: flex; gap: 14px; }
.couverture { width: 96px; height: 144px; object-fit: cover; border-radius: 5px; flex: none; box-shadow: var(--ombre); }
.couverture-vide { display: grid; place-items: center; background: var(--kraft); color: #fff;
  font: 600 2rem var(--serif); }
.case-mois { margin: 0; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
  font-weight: 700; }
.case-titre { font-size: 1.1rem; margin: 4px 0 2px; }
.case-cal, .mot, .profil, .commande dd { overflow-wrap: anywhere; }
.case-auteur { margin: 0; color: var(--encre-douce); font-size: .92rem; }
.case-de { margin: 8px 0 0; font-size: .9rem; }
.mot { margin: 14px 0 0; padding: 12px 14px; background: var(--fond); border-radius: 10px;
  font-family: var(--serif); font-style: italic; font-size: 1rem; position: relative; }
.mot footer { font-style: normal; font-family: var(--sans); font-size: .85rem; color: var(--encre-douce); margin-top: 6px; }
.case-revelee { animation: deballer .9s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes deballer {
  0% { transform: scale(.85) rotate(-4deg); opacity: 0; }
  60% { transform: scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: none; }
}
.confettis { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confettis i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
  animation: tomber 2.4s ease-in forwards; }
@keyframes tomber { to { transform: translateY(105vh) rotate(540deg); opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  .case-revelee, .paquet-merci, .confettis i { animation: none; }
  .confettis { display: none; }
}

/* ------------------------------------------------ Impression (libraire) */
@media print {
  .entete, .pied, .actions-libraire, .surtitre { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .commande-ligne { border: 1px solid #999; box-shadow: none; }
}

.bandeau-test { background: repeating-linear-gradient(45deg, #f1c67a 0 12px, #e8b55a 12px 24px); color: #2b2420;
  text-align: center; font-weight: 700; padding: 8px 16px; font-size: .9rem; }

/* Invitation d'un proche */
.invitation-grille { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .invitation-grille { grid-template-columns: 1fr; } }
.invitation-apercu { min-height: 200px; }
.invitation-image { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.12); }
.boutons { display: flex; flex-wrap: wrap; gap: 10px; }
.message-invitation { width: 100%; font: inherit; font-size: .95rem; padding: 10px; border-radius: 10px;
  border: 1px solid var(--trait); background: var(--surface); color: var(--encre); margin-bottom: 10px; }
.autres-invitations { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.autres-invitations .puce { text-decoration: none; padding: 4px 12px; }
.lien-invitation { margin-left: 4px; }
.carte-bon { display: flex; gap: 18px; align-items: center; }
.carte-bon img { width: 84px; height: auto; flex: none; }
@media (max-width: 560px) {
  .copie-proche { flex-wrap: wrap; }
  .copie-proche input { flex: 1 1 100%; }
  .copie-proche .bouton { flex: 1 1 0; }
}
