@import url('https://fonts.googleapis.com/css2?family=Cookie&family=Nunito+Sans:opsz,wght@6..12,400;6..12,600;6..12,700;6..12,800&display=swap');

:root {
  --vert-fonce: #043D22; --vert: #399135; --anis: #C0E75E; --menthe: #88F2B5;
  --rouge: #FE142B; --rouge-fonce: #BC1F27; --pain: #F8A678; --creme: #F7DCC4;
  --peche: #FFCC99; --fond: #FBF6EF; --taupe: #E9E0D4; --encre: #1F2A24; --gris: #6E7470;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Nunito Sans', 'Nunito', system-ui, Arial, sans-serif; color: var(--encre); background: var(--fond); }
body.no-scroll { overflow: hidden; }
button { font: inherit; cursor: pointer; }
.btn { border: 0; border-radius: 999px; padding: .55em 1.1em; background: var(--vert-fonce); color: #fff; font-weight: 700; display: inline-flex; align-items: center; gap: .4em; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: #fff; color: var(--vert-fonce); box-shadow: inset 0 0 0 1.5px var(--taupe); }
.btn.red { background: var(--rouge-fonce); }
.btn.small { padding: .35em .8em; font-size: .88em; }
.btn:disabled { opacity: .4; cursor: default; }

/* ================= CONFIGURATEUR ================= */
.cfg-top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--taupe); display: flex; align-items: center; gap: 16px; padding: 10px 20px; flex-wrap: wrap; }
.cfg-top h1 { font-size: 1.15rem; margin: 0; font-weight: 800; color: var(--vert-fonce); }
.cfg-top h1 small { display: block; font-weight: 600; color: var(--gris); font-size: .78rem; }
.counter { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.counter .num { font-weight: 800; font-size: 1.35rem; color: var(--vert-fonce); min-width: 4.2em; text-align: right; }
.counter .num.full { color: var(--vert); }
.counter .bar { width: 160px; height: 10px; background: var(--taupe); border-radius: 99px; overflow: hidden; }
.counter .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--vert), var(--anis)); transition: width .3s; }
.counter .hint { font-size: .8rem; color: var(--gris); }
.cfg { display: grid; grid-template-columns: 210px 1fr 340px; gap: 0; min-height: calc(100vh - 62px); }
.cats { padding: 16px 10px; border-right: 1px solid var(--taupe); position: sticky; top: 62px; align-self: start; }
.cats button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; padding: 9px 10px; border-radius: 10px; text-align: left; font-weight: 700; color: var(--encre); }
.cats button svg { width: 26px; height: 26px; flex: none; }
.cats button.on { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); color: var(--vert-fonce); }
.cats button .n { margin-left: auto; background: var(--vert); color: #fff; border-radius: 99px; font-size: .72rem; padding: 1px 7px; }
.cats button .n:empty { display: none; }
.catalog { padding: 18px 24px 60px; }
.type { margin-bottom: 28px; }
.type h3 { margin: 0; font-size: 1.05rem; color: var(--vert-fonce); }
.type p { margin: 2px 0 10px; color: var(--gris); font-size: .9rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { background: #fff; border-radius: var(--r); box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; border: 2px solid transparent; transition: border-color .15s; }
.card.sel { border-color: var(--vert); }
.card .thumb { aspect-ratio: 297/210; cursor: zoom-in; background: #fff; border-bottom: 1px solid #f0ebe4; position: relative; }
.card .thumb svg { width: 100%; height: 100%; display: block; }
.card .thumb .badge { position: absolute; top: 6px; left: 6px; background: var(--vert-fonce); color: #fff; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; }
.card .foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.card .lvl { font-weight: 700; font-size: .85rem; }
.card .lvl .dots { color: var(--pain); letter-spacing: 1px; }
.card .foot .sp { flex: 1; }
.icon-btn { border: 0; background: var(--fond); border-radius: 8px; width: 34px; height: 34px; font-size: 1rem; }
.icon-btn:hover { background: var(--taupe); }
.check { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--fond); border-radius: 8px; padding: 0 10px; height: 34px; font-weight: 700; color: var(--vert-fonce); }
.check i { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--vert-fonce); display: inline-grid; place-items: center; font-style: normal; font-size: 13px; color: #fff; }
.card.sel .check { background: var(--vert); color: #fff; }
.card.sel .check i { background: #fff; border-color: #fff; color: var(--vert); }
.stepper { display: inline-flex; align-items: center; background: var(--vert); border-radius: 8px; height: 34px; color: #fff; }
.stepper button { border: 0; background: none; color: #fff; width: 32px; height: 34px; font-size: 1.15rem; font-weight: 800; }
.stepper button:hover { background: rgba(0,0,0,.12); }
.stepper button:disabled { opacity: .35; }
.stepper b { min-width: 1.4em; text-align: center; }
.empty-perso { background: #fff; border-radius: var(--r); padding: 20px; color: var(--gris); line-height: 1.5; }

.side { border-left: 1px solid var(--taupe); background: #fff; padding: 16px 18px 40px; position: sticky; top: 62px; align-self: start; max-height: calc(100vh - 62px); overflow: auto; }
.side h2 { font-size: 1rem; margin: 18px 0 8px; color: var(--vert-fonce); }
.side h2:first-child { margin-top: 0; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 3px; }
.field input[type=text], .field select { width: 100%; padding: 8px 10px; border: 1.5px solid var(--taupe); border-radius: 10px; font: inherit; background: #fff; }
.field .note { font-size: .75rem; color: var(--gris); margin-top: 3px; }
.radios { display: flex; gap: 6px; flex-wrap: wrap; }
.radios label { display: inline-flex; gap: 5px; align-items: center; font-weight: 600; font-size: .86rem; background: var(--fond); padding: 5px 10px; border-radius: 99px; cursor: pointer; }
/* choix du style de vignettes */
.styles { display: grid; gap: 8px; }
.style-opt { display: flex; flex-direction: column; gap: 4px; align-items: stretch; border: 2px solid var(--taupe); background: var(--peche); border-radius: 12px; padding: 8px; text-align: left; }
.style-opt.on { border-color: var(--vert-fonce); box-shadow: 0 0 0 2px var(--anis); }
.style-opt .mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.style-opt .mini img, .style-opt .mini .tile { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.style-opt .mini .tile .fb b { font-size: 1rem; }
.style-opt .nm { font-weight: 700; font-size: .82rem; }
.days { list-style: none; margin: 0; padding: 0; counter-reset: d; }
.days li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; font-size: .84rem; }
.days li:nth-child(odd) { background: var(--fond); }
.days li b { width: 1.8em; text-align: right; color: var(--rouge-fonce); flex: none; }
.days li .lab { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.days li.vide .lab { color: #b7b0a6; font-style: italic; cursor: default; }
.days .grip { width: 18px; flex: none; text-align: center; color: #A9A196; cursor: grab; touch-action: none; user-select: none; font-size: 1rem; line-height: 1; }
.days li[data-d]:hover .grip { color: var(--vert-fonce); }
.days li.dragging { background: var(--anis) !important; box-shadow: 0 4px 14px rgba(0,0,0,.18); position: relative; z-index: 2; }
body.dragging-days, body.dragging-days * { cursor: grabbing !important; user-select: none; }
.days li button { border: 0; background: none; width: 22px; height: 22px; border-radius: 6px; color: var(--gris); padding: 0; }
.days li button:hover { background: var(--taupe); }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.linkbox { width: 100%; font-size: .75rem; padding: 8px; border-radius: 10px; border: 1.5px solid var(--taupe); resize: none; height: 70px; word-break: break-all; }
.saved { list-style: none; padding: 0; margin: 0; }
.saved li { display: flex; align-items: center; gap: 6px; font-size: .85rem; padding: 4px 0; border-bottom: 1px dashed var(--taupe); }
.saved li span { flex: 1; }
.saved li small { color: var(--gris); }
.gift-prev { width: 100%; aspect-ratio: 297/210; border-radius: 8px; border: 1px solid var(--taupe); overflow: hidden; cursor: zoom-in; margin-top: 6px; }
.gift-prev svg { width: 100%; height: 100%; display: block; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--vert-fonce); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 700; z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.2); animation: pop .2s; }
@keyframes pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } }

.modal { position: fixed; inset: 0; background: rgba(20,30,25,.55); z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal .box { background: #fff; border-radius: 18px; max-width: min(1100px, 96vw); width: 100%; padding: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal .box .big { aspect-ratio: 297/210; border: 1px solid var(--taupe); border-radius: 8px; overflow: hidden; max-height: 74vh; margin: 0 auto; }
.modal .box .big svg { width: 100%; height: 100%; display: block; }
.modal .box .mbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.modal .box .mbar h3 { margin: 0 auto 0 4px; color: var(--vert-fonce); font-size: 1.05rem; }

@media (max-width: 1100px) {
  .cfg { grid-template-columns: 1fr; }
  .cats { position: static; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--taupe); }
  .cats button { width: auto; white-space: nowrap; }
  .side { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--taupe); }
}

/* ================= CALENDRIER ================= */
body.cal { background: var(--peche); min-height: 100vh; }
.cal-head { text-align: center; padding: 18px 10px 4px; }
.cal-head .titre-img { max-width: min(900px, 92vw); display: block; margin: 0 auto; }
.cal-head h1 { font-family: 'Cookie', cursive; font-weight: 400; font-size: clamp(2.8rem, 7vw, 5.5rem); margin: 0; line-height: 1; color: #111; }
.cal-head .sous { font-family: 'Cookie', cursive; font-size: clamp(1.6rem, 3.4vw, 2.6rem); margin: 0; }
.cal-head .prenom { font-weight: 800; color: var(--rouge-fonce); margin-top: 6px; font-size: 1.1rem; }
.grid24 { display: grid; grid-template-columns: repeat(6, 1fr); gap: clamp(10px, 2vw, 26px); max-width: 1100px; margin: 18px auto 0; padding: 0 20px; }
@media (max-aspect-ratio: 1/1) { .grid24 { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: none; transition: transform .15s; }
.tile:hover { transform: scale(1.06) rotate(-2deg); }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .fb { width: 100%; height: 100%; border-radius: 22%; display: grid; place-items: center; position: relative; overflow: hidden; box-shadow: inset 0 -6px 0 rgba(0,0,0,.15); }
.tile .fb svg { position: absolute; width: 50%; height: 50%; left: 7%; bottom: 7%; background: rgba(255,255,255,.88); border-radius: 50%; padding: 7%; }
.tile .fb b { position: absolute; right: 10%; top: 6%; font-size: clamp(1.6rem, 4.5vw, 3rem); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.tile.done::after { content: '✓'; position: absolute; right: -4px; bottom: -4px; width: 30%; height: 30%; max-width: 34px; max-height: 34px; border-radius: 50%; background: var(--vert); color: #fff; display: grid; place-items: center; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.tile.locked { filter: saturate(.55); opacity: .8; }
.tile.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(6px) rotate(3deg); } }
.tile25 { display: flex; justify-content: center; margin: 26px 0 10px; }
.tile25 .tile { width: clamp(120px, 18vw, 190px); }
.cal-foot { text-align: center; padding: 20px 10px 40px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cal-foot .btn.ghost { background: rgba(255,255,255,.6); }
.apercu-band { background: var(--vert-fonce); color: #fff; text-align: center; padding: 6px; font-size: .9rem; font-weight: 700; }
.apercu-band a { color: var(--anis); }

/* ================= FICHE ================= */
.sheet-overlay { position: fixed; inset: 0; z-index: 150; background: #EDE6DC; display: flex; flex-direction: column; }
.sheet-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--taupe); flex-wrap: wrap; }
.sheet-title { font-weight: 800; color: var(--vert-fonce); }
.tools { display: flex; align-items: center; gap: 4px; margin: 0 auto; flex-wrap: wrap; }
.tool { border: 0; background: var(--fond); border-radius: 10px; height: 40px; padding: 0 10px; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 5px; }
.tool span { font-size: .82rem; font-weight: 700; }
.tool.on { background: var(--vert-fonce); color: #fff; }
.sizes { display: inline-flex; gap: 3px; margin: 0 6px; }
.size { width: 36px; height: 40px; border: 0; border-radius: 10px; background: var(--fond); display: grid; place-items: center; }
.size i { background: var(--encre); border-radius: 50%; display: block; }
.size.on { background: var(--anis); }
.bar-right { display: flex; gap: 6px; }
.palette { display: flex; gap: 6px; padding: 6px 12px; background: #fff; border-bottom: 1px solid var(--taupe); overflow-x: auto; justify-content: center; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); flex: none; }
.sw.on { outline: 3px solid var(--vert-fonce); outline-offset: 2px; }
.sheet-stage { flex: 1; display: grid; place-items: center; overflow: hidden; min-height: 0; }
.sheet { position: relative; background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.12); border-radius: 4px; }
.sheet canvas, .sheet .svg-host { position: absolute; inset: 0; width: 100%; height: 100%; }
.sheet .svg-host { pointer-events: none; }
.sheet .svg-host svg { width: 100%; height: 100%; display: block; }
.sheet canvas.pen { touch-action: none; cursor: crosshair; }
.sheet { container-type: inline-size; }
.sheet canvas.prev { pointer-events: none; }
.hot { position: absolute; inset: 0; pointer-events: none; }
.hz { position: absolute; border: 0; background: transparent; padding: 0; pointer-events: none; border-radius: 50%; box-sizing: border-box; }
.hot.touch .hz, .hz-coche, .hz-etoile { pointer-events: auto; cursor: pointer; }
.hot.touch .hz:hover { background: rgba(192, 231, 94, .18); }
.hz-rond.on { border: .55cqw solid var(--rouge); }
.hz-barre { border-radius: 3px; }
.hz-barre.on::after { content: ''; position: absolute; left: 12%; right: 12%; top: 50%; height: .5cqw; background: var(--rouge); border-radius: 9px; transform: rotate(-45deg); }
.hz-coche { border-radius: 4px; }
.hz-coche.on::before { content: '✓'; position: absolute; left: -.2cqw; top: 50%; transform: translateY(-55%); font-size: 3.2cqw; font-weight: 900; color: var(--vert); }
.hz-coche.on::after { content: ''; position: absolute; left: 3cqw; right: .3cqw; top: 52%; height: .25cqw; background: var(--vert); }
.hz-etoile { border-radius: 0; }
.hz-etoile svg { width: 100%; height: 100%; display: block; }
.hz-etoile svg polygon { fill: transparent; }
.hz-etoile.on svg polygon { fill: #F7C531; stroke: #1F2A24; stroke-width: .35; }
.hz-in { position: absolute; pointer-events: auto; border: 0; background: transparent; text-align: center; font-family: 'Nunito Sans', Arial, sans-serif; font-weight: 800; color: #1F2A24; padding: 0; outline: none; border-radius: 3px; }
.hz-in:focus { background: rgba(192, 231, 94, .3); }
.side-panel { background: #fff; border-top: 1px solid var(--taupe); padding: 10px 16px; max-height: 40vh; overflow: auto; }
.panel-head { font-weight: 800; color: var(--vert-fonce); display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.kbd-area { width: 100%; min-height: 120px; font: 1.3rem/1.5 Arial, sans-serif; border: 1.5px solid var(--taupe); border-radius: 10px; padding: 10px; }
.kb-row { display: grid; grid-template-columns: 1fr 1fr 30px; gap: 10px; align-items: center; margin-bottom: 8px; }
.kb-model { font: 1.3rem Arial, sans-serif; letter-spacing: .02em; }
.kb-model .ok { color: var(--vert); font-weight: 700; }
.kb-model .ko { color: var(--rouge); text-decoration: underline; }
.kb-in { font: 1.3rem Arial, sans-serif; padding: 6px 10px; border: 1.5px solid var(--taupe); border-radius: 10px; width: 100%; }
@media (max-width: 1180px) { .tool span { display: none; } .sheet-bar .btn span { display: none; } }
@media (max-width: 760px) { .tool span, .btn span { display: none; } .kb-row { grid-template-columns: 1fr; } }

/* ================= IMPRESSION ================= */
#print-area { display: none; }
@page { size: A4 landscape; margin: 0; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body.printing { background: #fff; }
  .print-page { width: 297mm; height: 209.5mm; page-break-after: always; break-after: page; overflow: hidden; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .print-page.portrait { width: 210mm; height: 296.5mm; }
  .print-page svg { width: 100%; height: 100%; display: block; }
}

/* Bouton « Écouter » pendant la lecture */
.btn[data-a="lire"].lit { background: #FFD04D; border-color: #E0B020; color: #3A302A; animation: lit-pulse 1.2s ease-in-out infinite; }
@keyframes lit-pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 208, 77, .35); } }
/* Barre de la fiche sur une seule ligne (tablettes) : le bouton Écouter garde son texte */
.sheet-title { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1440px) { .sheet-bar .bar-right .btn:not([data-a="lire"]) span, .sheet-bar .btn[data-a="close"] span { display: none; } }
@media (max-width: 1180px) { .sheet-bar .btn[data-a="lire"] span { display: inline; } .sheet-title { max-width: 140px; } }
@media (max-width: 1440px) { .tool { padding: 0 7px; } .sheet-title { max-width: 170px; } }

/* Zoom de la feuille */
.sheet-overlay { position: fixed; }
.sheet-stage { position: relative; touch-action: none; }
.sheet-stage.zoomed { display: block; overflow: auto; }
.sheet-stage.zoomed .sheet { margin: 8px auto; }
.sheet .hot { touch-action: none; }
.zoom-ctl { position: absolute; left: 14px; bottom: 14px; z-index: 5; display: flex; align-items: center; background: #fff; border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.15); padding: 4px; gap: 2px; }
.zoom-ctl button { border: 0; background: transparent; height: 40px; min-width: 40px; border-radius: 999px; font-size: 1.4rem; font-weight: 800; color: var(--vert-fonce); cursor: pointer; }
.zoom-ctl button:hover { background: var(--fond); }
.zoom-ctl .zoom-val { font-size: .85rem; min-width: 58px; }
@media print { .zoom-ctl { display: none; } }

/* Cases de saisie larges (textes à trous) : vides et outil de dessin actif -> on écrit au stylet dessus */
.hot.trace .hz-in.large.vide { pointer-events: none; }
.hz-in.large { text-align: left; padding-left: .6cqw; font-family: 'Andika', 'Nunito Sans', Arial, sans-serif; font-weight: 700; }

/* Choix du cadeau du 25 par le jeune */
.cadeaux-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; max-height: 76vh; overflow: auto; padding: 4px; }
.cadeau-carte { border: 2px solid var(--taupe); border-radius: 14px; background: #fff; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: stretch; font: inherit; font-weight: 800; color: var(--vert-fonce); transition: transform .15s, border-color .15s; }
.cadeau-carte:hover, .cadeau-carte:focus-visible { transform: translateY(-3px); border-color: var(--vert); }
.cadeau-carte .mini { aspect-ratio: 297/210; border-radius: 8px; overflow: hidden; border: 1px solid var(--taupe); }
.cadeau-carte .mini svg { width: 100%; height: 100%; display: block; }
.cadeau-carte.vu span::after { content: ' ✓'; color: var(--vert); }
.gift-choix { font-size: .85rem; padding: 8px 10px; background: #FFF6EC; border-radius: 10px; }
.gift-choix ul { margin: 4px 0 0; padding-left: 18px; }
