:root {
  --cream: #fbf3e4; --paper: #fffaf0; --red: #b3261e; --red-d: #8c1c16; --green: #1f5d3a; --green-l: #2f7d51;
  --gold: #d9a441; --ink: #3a2a22; --muted: #85705f; --line: #ead9bf;
  --shadow: 0 6px 18px rgba(80, 40, 20, .13);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); font: 16px/1.5 'Nunito', system-ui, sans-serif; min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(179, 38, 30, .07), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(31, 93, 58, .08), transparent 45%),
    var(--cream);
}
body.noscroll { overflow: hidden; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--green); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px 60px; position: relative; z-index: 6; }
[hidden] { display: none !important; }

/* guirlande */
.garland { height: 34px; position: relative; z-index: 6; background:
  radial-gradient(circle at 20px 8px, var(--red) 7px, transparent 8px) 0 0 / 80px 34px repeat-x,
  radial-gradient(circle at 60px 12px, var(--gold) 7px, transparent 8px) 0 0 / 80px 34px repeat-x,
  radial-gradient(circle at 40px 8px, var(--green-l) 7px, transparent 8px) 0 0 / 80px 34px repeat-x; }
.garland::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--green); }

.hero { text-align: center; padding: 22px 0 6px; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3.3rem); color: var(--red-d); letter-spacing: -.5px; line-height: 1.1; }
.hero p { max-width: 640px; margin: 10px auto 0; color: var(--muted); font-size: 1.05rem; white-space: pre-line; }
.progress { margin: 16px auto 4px; max-width: 360px; text-align: center; }
.bar { height: 10px; border-radius: 99px; background: #eadbc4; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-l), var(--green)); border-radius: 99px; transition: width .6s; }
.progress small { color: var(--muted); font-weight: 700; }
.back { display: inline-block; margin-top: 14px; font-weight: 800; text-decoration: none; }
.banner { background: #ffe1a8; color: #6b4a00; border: 2px dashed #d9a441; border-radius: 12px; padding: 10px 14px; margin-top: 14px; font-weight: 700; text-align: center; }

/* barre d'outils */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.seg { display: inline-flex; background: #f1e3cb; border-radius: 99px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 99px; padding: 7px 14px; font-weight: 800; color: var(--muted); }
.seg button.on { background: #fff; color: var(--red-d); box-shadow: 0 2px 6px rgba(80, 40, 20, .12); }
.seg button b { font-weight: 800; opacity: .7; margin-left: 2px; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); margin-top: 20px; }

/* cartes */
.card { background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; position: relative; transition: transform .2s; }
.card:hover { transform: translateY(-3px) rotate(-.3deg); }
.admin-card:hover { transform: none; }
.pic { aspect-ratio: 1; background: #fff; display: grid; place-items: center; position: relative; overflow: hidden; border: 0; padding: 0; width: 100%; }
button.pic { cursor: zoom-in; }
.pic img { width: 100%; height: 100%; object-fit: contain; padding: 10px; transition: filter .4s, opacity .4s; }
.pic .noimg { font-size: 4rem; }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card h3 { font-size: 1.15rem; line-height: 1.2; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.price { font-weight: 800; color: var(--green); }
.qty { font-size: .85rem; font-weight: 800; color: var(--muted); }
.grow { flex: 1; }
.mine-note { font-size: .85rem; font-weight: 800; color: var(--green); }

.btn { border: 0; border-radius: 99px; padding: 10px 18px; font-weight: 800; background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-d); transition: transform .1s, box-shadow .1s, background .15s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: #c42e25; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-d); }
.btn.green { background: var(--green); box-shadow: 0 3px 0 #123d25; }
.btn.green:hover { background: var(--green-l); }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.ghost.warn { color: var(--red); border-color: #f0c4bf; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.link-small { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: .85rem; padding: 0; }

/* pris */
.card.taken .pic img { filter: saturate(.4) brightness(.97); opacity: .7; }
.stamp { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.stamp .check { width: 92px; height: 92px; border-radius: 50%; background: rgba(31, 93, 58, .93); color: #fff; display: grid; place-items: center; font-size: 3.2rem; font-weight: 900; border: 5px solid #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); transform: rotate(-10deg); }
.pop .stamp .check { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(0) rotate(-60deg); } to { transform: scale(1) rotate(-10deg); } }
.sticker { position: absolute; top: 8px; right: 8px; font-size: 2rem; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); transform: rotate(12deg); }

/* étiquettes */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: #fff3c9; border: 1.5px dashed #c99a2e; padding: 4px 12px 4px 22px; font-weight: 800; border-radius: 4px 14px 14px 4px; position: relative; color: #6b4a00; font-size: .95rem; }
.tag::before { content: ''; position: absolute; left: 7px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--cream); border: 1.5px solid #c99a2e; }
button.tag:hover { background: #ffeaa3; }
.tag.mine { background: #e3f3e8; border-color: var(--green-l); color: var(--green); }
.tag.mine::before { border-color: var(--green-l); }
.tag .ed { font-size: .8rem; opacity: .7; }
.tag .x { border: 0; background: none; padding: 0 0 0 2px; color: inherit; font-weight: 900; opacity: .6; }
.tag .x:hover { opacity: 1; color: var(--red); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); grid-column: 1 / -1; }
.empty .big { font-size: 4rem; }
.empty h2 { color: var(--ink); margin: 6px 0; }

/* modales */
.modal-bg { position: fixed; inset: 0; background: rgba(40, 20, 10, .55); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s; overflow: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--paper); border-radius: 20px; padding: 22px; width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border-top: 8px solid var(--red); max-height: calc(100vh - 32px); overflow: auto; }
.modal.wide { width: min(880px, 100%); }
.modal h2 { color: var(--red-d); margin-bottom: 4px; overflow-wrap: anywhere; }
.modal p { margin: 4px 0 12px; color: var(--muted); }
.modal h4 { margin: 14px 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 99px; padding: 0; font-weight: 800; display: inline-flex; align-items: center; overflow: hidden; }
.chip > button { border: 0; background: none; padding: 6px 14px; font-weight: 800; }
button.chip { padding: 6px 14px; }
.chip > button.x { padding: 6px 10px 6px 0; color: var(--muted); }
.chip > button.x:hover { color: var(--red); }
.chip.on { border-color: var(--green); background: #e6f4ea; color: var(--green); }
input[type=text], input[type=password], input[type=url], input[type=number], textarea { width: 100%; padding: 9px 12px; border-radius: 10px; border: 2px solid var(--line); background: #fff; min-width: 0; }
input:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.actions .left { margin-right: auto; }
.err { color: var(--red); font-weight: 700; min-height: 1.4em; margin-top: 6px; font-size: .95rem; }
.lb img { width: 100%; max-height: 62vh; object-fit: contain; background: #fff; border-radius: 12px; }
.lb .noimg { font-size: 6rem; text-align: center; }
.label-row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.label-row input { flex: 1; }
.label-row [data-def]:disabled { opacity: 1; cursor: default; border-color: var(--gold); background: #fff8e6; }

/* toasts */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 90; width: min(420px, calc(100% - 32px)); }
.toast { background: #2d3b2f; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); display: flex; gap: 12px; align-items: center; justify-content: space-between; font-weight: 700; animation: up .25s; transition: opacity .3s, transform .3s; }
.toast.error { background: var(--red-d); }
.toast button { background: #fff; color: var(--green); border: 0; border-radius: 99px; padding: 4px 12px; font-weight: 800; }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }

/* neige */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.snow span { position: absolute; top: -20px; color: #fff; text-shadow: 0 0 4px rgba(120, 140, 170, .7); animation: fall linear infinite; opacity: .85; }
@keyframes fall { to { transform: translateY(105vh) translateX(40px); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } * { animation-duration: .01ms !important; } }
.confetti { position: fixed; top: -30px; z-index: 80; pointer-events: none; animation: drop 2.2s ease-in forwards; }
@keyframes drop { to { transform: translateY(110vh) rotate(540deg); } }

/* listes (accueil + admin) */
.lists { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 22px; }
.list-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .2s; }
a.list-card:hover { transform: translateY(-3px); }
.list-card .cover { height: 150px; background: #fff center / contain no-repeat; display: grid; place-items: center; font-size: 3.4rem; border-bottom: 1px solid var(--line); }
.list-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.list-card h3 { font-size: 1.3rem; color: var(--red-d); overflow-wrap: anywhere; }

/* accueil + code */
.entry { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; max-width: 820px; margin: 10px auto 0; }
.entry .panel { margin-top: 0; }
@media (max-width: 640px) { .entry { grid-template-columns: 1fr; } }
.section-title { color: var(--green); font-size: 1.3rem; margin-top: 34px; }
.list-card.mini .body { gap: 10px; }
.code { display: flex; gap: 10px; justify-content: center; margin: 16px 0 8px; }
.code span { width: 58px; height: 70px; display: grid; place-items: center; background: #fff; border: 3px solid var(--gold); border-radius: 12px; font: 800 2.3rem 'Fraunces', Georgia, serif; color: var(--red-d); box-shadow: 0 3px 0 #c99a2e; }
.code.small { justify-content: flex-start; margin: 4px 0; gap: 6px; }
.code.small span { width: 38px; height: 46px; font-size: 1.5rem; border-width: 2px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; font-size: 1.2rem; text-align: center; }
.code-input::placeholder { color: #d8c6ab; }

/* admin */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.2rem; margin-bottom: 10px; color: var(--green); }
.drop { border: 3px dashed var(--gold); border-radius: 16px; padding: 24px; text-align: center; background: #fff8e6; color: var(--muted); font-weight: 700; transition: background .2s; cursor: pointer; }
.drop.over, .drop:hover { background: #ffeebd; }
.drop b { color: var(--red-d); }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label:not(.switch), .lbl { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.slug { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.slug span { padding: 0 0 0 12px; color: var(--muted); white-space: nowrap; font-size: .9rem; }
.slug input { border: 0 !important; padding-left: 2px; }
.admin-card .body { gap: 8px; }
.admin-card input { padding: 7px 10px; font-size: .95rem; }
.pic-tools { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; }
.pic-tools button { border: 0; background: rgba(255, 255, 255, .94); border-radius: 99px; padding: 5px 10px; font-weight: 800; font-size: .8rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.pic-tools button:hover { background: #fff; color: var(--red-d); }
.switch { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; cursor: pointer; }
.switch input { width: 46px; height: 26px; appearance: none; background: #cdbca4; border-radius: 99px; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked { background: var(--green-l); }
.switch input:checked::after { left: 23px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.badge.draft { background: #ffe1a8; color: #7a5200; }
.badge.live { background: #cdeed7; color: #14502e; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
/* outil « entourer » : fenêtre de hauteur fixe, l'image se réduit pour tenir, rien ne défile */
.modal.crop { width: min(1000px, 100%); height: calc(100vh - 32px); height: calc(100dvh - 32px); max-height: none; overflow: hidden; display: flex; flex-direction: column; padding: 16px 18px; }
.crop-head p { margin: 2px 0 10px; }
.cropwrap { position: relative; flex: 1; min-height: 120px; background: #f1e6d0; border-radius: 12px; overflow: hidden; }
.cropwrap canvas { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; cursor: crosshair; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-foot { flex-shrink: 0; padding-top: 8px; }
.crop-foot .hint { margin: 0 0 8px; min-height: 1.4em; }
@media (max-width: 520px) { .modal.crop { padding: 12px; } .crop-head h2 { font-size: 1.2rem; } .crop-head p { font-size: .9rem; } }

/* éditeur : barre compacte + cartes simples */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.topbar .switch { font-weight: 700; color: var(--muted); }
.code-chip b { letter-spacing: .15em; color: var(--red-d); }
#drop { margin-top: 14px; padding: 16px; font-size: .95rem; }
.title-input { border-color: transparent !important; background: transparent !important; font: 800 1.08rem 'Fraunces', Georgia, serif !important; padding: 4px 6px !important; margin: -4px -6px 0; width: calc(100% + 12px) !important; color: var(--ink); }
.title-input:hover { border-color: var(--line) !important; background: #fff !important; }
.title-input:focus { border-color: var(--gold) !important; background: #fff !important; }
.details { border: 0; background: none; padding: 0; text-align: left; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.details:hover { color: var(--red-d); }
.details .add { color: var(--gold); font-weight: 800; }
.admin-card .pic { cursor: pointer; }
.edit-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; margin-top: 12px; }
.edit-pic .pic { border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 640px) { .edit-grid { grid-template-columns: 1fr; } .edit-pic .pic { max-width: 220px; margin: 0 auto; } }
.recap { width: 100%; border-collapse: collapse; }
.recap td { padding: 8px 6px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.recap td:first-child { font-weight: 800; white-space: nowrap; width: 1%; padding-right: 18px; }
.split { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
footer { text-align: center; color: var(--muted); padding: 30px 0 10px; font-size: .9rem; }
footer a { color: var(--muted); }
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card .body { padding: 10px; }
  .card h3 { font-size: 1rem; }
  .btn { padding: 9px 12px; }
  .stamp .check { width: 66px; height: 66px; font-size: 2.3rem; }
  .sticker { font-size: 1.5rem; }
  .seg button { padding: 6px 10px; font-size: .9rem; }
}
