/* My baby fantasy — style de l'appli (beige, crème, rose poudré) */
:root {
  --bg: #EFE6DA; --bg2: #E7DBCB; --creme: #FBF7F1; --texte: #5A4636; --texte2: #7A6250; --ligne: #DCCAB3;
  --cadre: #B89E80; --accent: #EBCFC2; --brun: #6B4F3A; --cuir: #CDB79E; --cuir2: #BFA688;
  --rad: 18px; --sh: 0 10px 30px rgba(90, 70, 54, .14), 0 2px 6px rgba(90, 70, 54, .08);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--texte); font: 400 16px/1.45 'Nunito', system-ui, sans-serif; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow-x: hidden; }
#bgdeco { position: fixed; inset: 0; pointer-events: none; opacity: .5; z-index: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #F7EFE4 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #F3E2D8 0, transparent 60%); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- En-tête ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(239, 230, 218, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid rgba(184, 158, 128, .25); }
.brand { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; display: flex; flex-direction: column; }
.brand-t { font: 600 22px/1.1 'Fraunces', serif; }
.brand-s { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--texte2); }
.top-act { display: flex; align-items: center; gap: 8px; }
main { position: relative; z-index: 1; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 999px;
  padding: 10px 18px; font-weight: 800; cursor: pointer; transition: transform .15s, background .2s, box-shadow .2s; user-select: none; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--texte); color: var(--creme); box-shadow: 0 6px 16px rgba(90, 70, 54, .25); }
.btn.primary:hover { background: #4b3a2c; }
.btn.ghost { background: var(--creme); border-color: var(--ligne); color: var(--texte); }
.btn.ghost:hover { border-color: var(--cadre); }
.btn.danger { color: #9b4a3c; }
.btn.big { padding: 14px 22px; font-size: 17px; width: 100%; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; stroke-width: 2.4; }
.ico-btn { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--ligne); background: var(--creme); display: grid; place-items: center; cursor: pointer; color: var(--texte); }
.ico-btn:disabled { opacity: .35; cursor: default; }
.lnk { background: none; border: 0; color: var(--texte2); font-weight: 800; text-decoration: underline; cursor: pointer; font-size: 14px; }
@media (max-width: 520px) { #btnNew span { display: none; } #btnNew { width: 42px; height: 42px; padding: 0; } }

.seg { display: inline-flex; background: var(--bg2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 7px 14px; font-weight: 800; font-size: 14px; color: var(--texte2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--creme); color: var(--texte); box-shadow: 0 1px 4px rgba(90, 70, 54, .15); }
.seg.wide { display: flex; flex-wrap: wrap; border-radius: 16px; }
.seg.wide button { flex: 1; border-radius: 13px; }

/* ---------- Classeur ---------- */
#s-binder { display: flex; flex-direction: column; align-items: center; padding: 12px 10px 18px; min-height: calc(100dvh - 66px); }
.binder-bar { width: min(100%, 720px); display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.count { font-size: 13px; font-weight: 800; color: var(--texte2); letter-spacing: .04em; }
.binder-stage { position: relative; perspective: 2000px; touch-action: pan-y; }
.binder { position: relative;
  width: min(calc(100vw - 20px), calc((100dvh - 190px) * .735), 640px);
  aspect-ratio: .735; border-radius: 20px; padding: 14px 14px 14px 30px;
  background: linear-gradient(135deg, var(--cuir), var(--cuir2)); box-shadow: var(--sh), inset 0 0 0 2px rgba(255, 255, 255, .25); }
.binder::before { /* coutures du cuir */
  content: ""; position: absolute; inset: 6px; border: 1.5px dashed rgba(251, 247, 241, .55); border-radius: 15px; pointer-events: none; }
.page { position: absolute; inset: 14px 14px 14px 30px; border-radius: 12px; background: var(--creme);
  box-shadow: inset 0 0 0 1px rgba(184, 158, 128, .25), 2px 0 0 #F4ECE0, 4px 1px 0 #EDE3D4;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3.2%; padding: 4.2% 4.2% 4.2% 7%;
  transform-origin: left center; backface-visibility: hidden; }
.page .rings { position: absolute; left: 1.2%; top: 0; bottom: 0; width: 4%; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; pointer-events: none; }
.page .rings i { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff 0 15%, #d8c9b5 40%, #a99073 100%); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.page.leaving { animation: leave .55s cubic-bezier(.45, .05, .35, 1) forwards; z-index: 3; }
.page.coming { animation: come .55s cubic-bezier(.45, .05, .35, 1) forwards; z-index: 3; }
@keyframes leave { to { transform: rotateY(-108deg); filter: brightness(.82); opacity: .2; } }
@keyframes come { from { transform: rotateY(-108deg); filter: brightness(.82); opacity: .2; } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .page.leaving, .page.coming { animation-duration: .01s; } }

.pocket { position: relative; border-radius: 8px; background: rgba(239, 230, 218, .45);
  box-shadow: inset 0 1px 3px rgba(90, 70, 54, .14), inset 0 0 0 1px rgba(184, 158, 128, .28); display: grid; place-items: center; min-width: 0; min-height: 0; }
.pocket::after { /* pochette plastique */
  content: ""; position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 35%), linear-gradient(to bottom, rgba(255, 255, 255, .5) 0 1.5px, transparent 1.5px); }
.empty { width: 92%; height: 94%; border: 1.5px dashed rgba(184, 158, 128, .55); border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; padding: 6px; color: var(--cadre); }
.empty b { font: 600 clamp(14px, 3.4vw, 22px)/1 'Fraunces', serif; color: var(--cadre); }
.empty span { font-size: clamp(8px, 1.9vw, 11.5px); font-weight: 700; line-height: 1.2; color: #a68d72; }
.empty img { width: 34%; opacity: .25; margin-bottom: 2px; }
.empty.add { cursor: pointer; } .empty.add:hover { background: rgba(235, 207, 194, .25); }

/* Carte dans la pochette : s'incline et brille sous le doigt (comme l'épopée) */
.tcard { position: relative; width: 92%; height: 94%; border-radius: 6px; cursor: pointer; transition: transform .35s ease, box-shadow .3s; transform-style: preserve-3d;
  box-shadow: 0 3px 8px rgba(90, 70, 54, .22); --mx: 50%; --my: 35%; --tilt: 0; }
.tcard img { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.tcard.is-tilting { transition: transform .06s linear, box-shadow .3s; box-shadow: 0 12px 26px rgba(90, 70, 54, .3); z-index: 2; }
.glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: calc(var(--tilt) * .9); transition: opacity .3s;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%); mix-blend-mode: soft-light; }
.sheen { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; overflow: hidden; }
.sheen::after { content: ""; position: absolute; top: -20%; bottom: -20%; width: 30%; left: -45%; transform: skewX(-18deg);
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent); animation: sweep 9s ease-in-out infinite; mix-blend-mode: soft-light; }
@keyframes sweep { 0%, 70% { left: -45%; } 90%, 100% { left: 125%; } }
@media (prefers-reduced-motion: reduce) { .sheen::after { display: none; } }

.binder-nav { display: flex; align-items: center; gap: 16px; margin-top: 14px; font-weight: 800; color: var(--texte2); }

/* ---------- Loupe ---------- */
.loupe { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 18px;
  background: rgba(62, 47, 36, .62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transition: opacity .25s; }
.loupe.open { opacity: 1; }
.loupe .close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.l-stage { perspective: 1600px; }
.fcard { position: relative; cursor: pointer; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .3, 1); --mx: 50%; --my: 35%; --tilt: 0; }
.fcard .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .3, 1); }
.fcard.flipped .inner { transform: rotateY(180deg); }
.fcard .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 3.2%/2.4%; overflow: hidden; box-shadow: 0 24px 60px rgba(30, 20, 12, .45); }
.fcard .face img { width: 100%; height: 100%; display: block; }
.fcard .face.back { transform: rotateY(180deg); }
.fcard.is-tilting { transition: transform .06s linear; }
.fcard .maplink { position: absolute; display: block; border-radius: 8px; }
.loupe.open .fcard { animation: pop .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.l-hint { margin: 0; color: rgba(251, 247, 241, .8); font-size: 13px; font-weight: 700; }
.l-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; }
.l-bar .btn.ghost { background: rgba(251, 247, 241, .94); }

/* ---------- Créateur ---------- */
.ed { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 14px; max-width: 1100px; margin: 0 auto; }
@media (min-width: 900px) { .ed { grid-template-columns: minmax(380px, 1fr) minmax(380px, 460px); align-items: start; } .ed-preview { position: sticky; top: 80px; } }
.ed-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ed-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ed-canvas-wrap { position: relative; touch-action: none; }
#edCanvas { display: block; border-radius: 22px; box-shadow: var(--sh); cursor: grab; background: var(--bg2); }
#edCanvas.grabbing { cursor: grabbing; }
.ed-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(90, 70, 54, .78); color: var(--creme); font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none; transition: opacity .4s; }
.ed-zoom { display: flex; align-items: center; gap: 8px; width: min(100%, 420px); color: var(--texte2); }
.ed-zoom input { flex: 1; accent-color: var(--texte); }
.quality { font-size: 13px; font-weight: 800; padding: 6px 12px; border-radius: 10px; text-align: center; max-width: 420px; }
.quality.ok { background: #E3EAD6; color: #4F6334; } .quality.moyen { background: #F4E4C8; color: #7A5A22; } .quality.faible { background: #F2D6CF; color: #8C3E30; }

.ed-form, .panel { display: flex; flex-direction: column; gap: 14px; }
.panel { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }
.panel h2 { font: 600 22px 'Fraunces', serif; margin: 18px 0 0; }
fieldset, details.deco { border: 0; margin: 0; padding: 16px; background: rgba(251, 247, 241, .85); border-radius: var(--rad); box-shadow: 0 1px 0 rgba(184, 158, 128, .25); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
legend { float: left; width: 100%; padding: 0; font: 600 19px 'Fraunces', serif; display: flex; align-items: center; gap: 10px; }
summary { font: 600 19px 'Fraunces', serif; cursor: pointer; display: flex; align-items: center; gap: 10px; list-style: none; }
summary::-webkit-details-marker { display: none; }
.step { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); display: inline-grid; place-items: center; font: 800 14px 'Nunito', sans-serif; flex-shrink: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 800; color: var(--texte2); min-width: 0; }
.opt { font-weight: 600; color: #a28b74; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1.5px solid var(--ligne); background: #fff; border-radius: 12px; padding: 11px 12px; font-size: 16px; font-weight: 600; color: var(--texte); outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--cadre); box-shadow: 0 0 0 3px rgba(235, 207, 194, .55); }
textarea { resize: vertical; line-height: 1.4; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .row3 { grid-template-columns: 1fr; } }
.note { margin: 0; font-size: 13px; color: var(--texte2); font-weight: 600; }
.note.warn { color: #8C3E30; }
.check { flex-direction: row; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--texte); }
.color input { width: 100%; height: 44px; border: 1.5px solid var(--ligne); border-radius: 12px; background: #fff; padding: 4px; }
.photo-drop { position: relative; flex-direction: row; align-items: center; justify-content: center; gap: 12px; padding: 18px; border: 2px dashed var(--cadre); border-radius: 16px; background: #fff; cursor: pointer; color: var(--texte); font-size: 16px; }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-drop svg { width: 34px; height: 34px; stroke-width: 1.6; }
.photo-drop.has { border-style: solid; background: #F7F1E8; }
.geo-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lab { margin: 4px 0 0; font-size: 14px; font-weight: 800; color: var(--texte2); }
.stk-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x mandatory; }
.stk-row button { flex: 0 0 64px; height: 64px; border-radius: 14px; border: 2px solid transparent; background: #fff; display: grid; place-items: center; cursor: pointer; scroll-snap-align: start; }
.stk-row button.on { border-color: var(--texte); background: #F7EDE6; }
.stk-row img { max-width: 48px; max-height: 48px; }
.ed-actions { display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; }
.ed-actions2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ed-actions2 .btn { padding: 10px 8px; font-size: 14px; }
@media (max-width: 420px) { .ed-actions2 { grid-template-columns: 1fr; } }

/* ---------- Divers ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 80; opacity: 0; pointer-events: none;
  background: var(--texte); color: var(--creme); padding: 12px 18px; border-radius: 14px; font-weight: 700; box-shadow: var(--sh); transition: .3s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.busy { position: fixed; inset: 0; z-index: 90; background: rgba(239, 230, 218, .75); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 800; }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--ligne); border-top-color: var(--texte); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- Porte d'entrée ---------- */
.door { min-height: calc(100dvh - 70px); display: grid; place-items: center; padding: 20px; }
.door-card { width: min(100%, 380px); background: var(--creme); border-radius: 26px; padding: 28px 22px; box-shadow: var(--sh); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.door-card img { width: 90px; }
.door-card h1 { margin: 0; font: 600 28px 'Fraunces', serif; }
.door-card p { margin: 0; color: var(--texte2); font-weight: 600; }
.door-card input { text-align: center; font-size: 20px; letter-spacing: .08em; text-transform: uppercase; }
body.at-door .top-act, body.at-door .brand-s { visibility: hidden; }
body:not(.is-cloud) .cloud-only { display: none !important; }
.draft-tag { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 3; background: var(--texte); color: var(--creme); font-size: 9px; font-weight: 800; letter-spacing: .08em; padding: 2px 7px; border-radius: 999px; pointer-events: none; }
.check.pub { justify-content: center; font-size: 15px; color: var(--texte); }

.door-card input.pseudo { text-transform: none; letter-spacing: 0; font-size: 17px; }
.notif-bar { width: min(100%, 720px); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--creme); border: 1.5px solid var(--accent); border-radius: 16px; padding: 10px 14px; margin-bottom: 10px; font-weight: 700; font-size: 14px; }
.notif-bar span { flex: 1; min-width: 180px; }
.fam-list { display: flex; flex-direction: column; gap: 8px; }
.fam-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid var(--ligne); border-radius: 14px; padding: 10px 12px; }
.fam-row b { font-size: 16px; } .fam-row .meta { flex: 1; min-width: 0; font-size: 12px; color: var(--texte2); font-weight: 600; }
.fam-row.revoked { opacity: .55; } .fam-row.revoked b { text-decoration: line-through; }
code { background: var(--bg2); padding: 1px 6px; border-radius: 6px; }
