/* ============ minichefpaint : style Miffy / Gloomy Bear ============ */
:root {
  --ink: #2A2523;
  --cream: #FFF4E0;
  --paper: #FFFDF8;
  --red: #E8412F;
  --orange: #F59A23;
  --yellow: #FFCB3D;
  --green: #3E9B5C;
  --blue: #2C6BC4;
  --pink: #F48FB1;
  --pink-l: #FFD9E6;
  --gloomy: #F7A8C2;
  --lav: #C3B1F0;
  --mint: #9EE0C2;
  --sky: #9FD3F5;
  --peach: #FFC9A8;
  --line: 3px;
  --r: 22px;
  --tools-w: 88px;   /* bouton 58 + marge 2×12 + bordure 2×3 */
  --panel-w: 300px;
  --col-gap: 22px;
  --frame-free: 340px; /* hauteur réservée hors toile (en-tête, palette, marge du bas…) */
  --peek-space: 104px; /* place au-dessus de la toile pour Miffy et Gloomy */
  --shadow: 5px 5px 0 var(--ink);
  --shadow-s: 3px 3px 0 var(--ink);
  --font: "Fredoka", "Arial Rounded MT Bold", "Varela Round", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--cream);
  /* vichy rose tout doux */
  background-image:
    linear-gradient(90deg, rgba(247,168,194,.22) 50%, transparent 50%),
    linear-gradient(rgba(247,168,194,.22) 50%, transparent 50%);
  background-size: 44px 44px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

svg { stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }

.card {
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---------- déco flottante ---------- */
.deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.band-deco { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.float {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--s, 30px); height: var(--s, 30px);
  object-fit: contain;
  opacity: .92;
  animation: bob var(--d, 7s) ease-in-out var(--dl, 0s) infinite;
}
.float.twinkle { animation-name: twinkle; }
@keyframes bob {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50% { transform: translate(4px, -12px) rotate(8deg); }
}
@keyframes twinkle {
  0%, 100% { transform: scale(.75) rotate(0deg); opacity: .55; }
  50% { transform: scale(1.1) rotate(25deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .float, .peek-miffy, .mascot { animation: none; }
}

/* ---------- en-tête ---------- */
/* l'en-tête reprend les colonnes de l'atelier (outils | toile | panneau)
   pour que la barre d'export soit centrée pile au-dessus du cadre */
.topbar {
  position: relative; z-index: 2;
  display: grid;
  grid-template-columns: var(--tools-w) minmax(0, 1fr) var(--panel-w);
  column-gap: var(--col-gap); row-gap: 12px;
  align-items: center;
  padding: 14px 24px 6px;
}
.topbar .brand { grid-row: 1; grid-column: 1 / 3; justify-self: start; }
.topbar .io-bar { grid-row: 1; grid-column: 2; justify-self: center; position: relative; z-index: 1; }
.topbar .actions { grid-row: 1; grid-column: 3; justify-self: end; }
.brand { display: flex; align-items: center; gap: 12px; }
.mascot {
  width: 66px; height: 66px;
  object-fit: contain;
  /* petit contour blanc façon sticker + ombre plate */
  filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff)
          drop-shadow(3px 3px 0 rgba(42, 37, 35, .35));
  animation: wiggle 4s ease-in-out infinite;
  transform-origin: 50% 90%;
  user-select: none;
}
@keyframes wiggle { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-8deg); } 95% { transform: rotate(6deg); } }

.logo { margin: 0; font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: 1px; display: flex; }
.logo span {
  display: inline-block;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--ink);
  transition: transform .2s;
}
.logo span:nth-child(6n+1) { color: var(--red);    transform: rotate(-6deg); }
.logo span:nth-child(6n+2) { color: var(--yellow); transform: translateY(-3px) rotate(4deg); }
.logo span:nth-child(6n+3) { color: var(--blue);   transform: rotate(-3deg); }
.logo span:nth-child(6n+4) { color: var(--gloomy); transform: translateY(2px) rotate(5deg); }
.logo span:nth-child(6n+5) { color: var(--green);  transform: rotate(-4deg); }
.logo span:nth-child(6n+6) { color: var(--orange); transform: translateY(-2px) rotate(3deg); }
.logo:hover span { animation: hop .5s ease both; }
.logo:hover span:nth-child(2) { animation-delay: .04s; } .logo:hover span:nth-child(3) { animation-delay: .08s; }
.logo:hover span:nth-child(4) { animation-delay: .12s; } .logo:hover span:nth-child(5) { animation-delay: .16s; }
.logo:hover span:nth-child(6) { animation-delay: .2s; }  .logo:hover span:nth-child(7) { animation-delay: .24s; }
.logo:hover span:nth-child(8) { animation-delay: .28s; } .logo:hover span:nth-child(9) { animation-delay: .32s; }
.logo:hover span:nth-child(10) { animation-delay: .36s; } .logo:hover span:nth-child(11) { animation-delay: .4s; }
.logo:hover span:nth-child(12) { animation-delay: .44s; } .logo:hover span:nth-child(13) { animation-delay: .48s; }
@keyframes hop { 50% { transform: translateY(-10px); } }

.tagline { margin: 6px 0 0 2px; font-weight: 500; font-size: 15px; opacity: .8; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- barre export / impression (en haut au milieu) ---------- */
.io-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 7px;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  box-shadow: 4px 4px 0 var(--ink);
}
.seg-format { height: 46px; border-width: var(--line); border-radius: 16px; }
.seg-format button { padding: 0 12px; font-size: 14px; font-weight: 700; letter-spacing: .5px; }
.seg-format button + button { border-left-width: var(--line); }
.seg-format button.on { background: var(--pink); }
#exportBtn b { font-weight: 700; }
.btn-print { background: var(--lav); }
.btn-print:hover { background: #d4c6f6; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 16px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-s);
  font-weight: 600; font-size: 16px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.btn svg { width: 24px; height: 24px; flex: none; }
.btn:hover { background: var(--pink-l); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: var(--shadow-s); background: #fff; }
.btn-primary { background: var(--yellow); }
.btn-primary:hover { background: #ffd866; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #f05a49; }
.icon-btn { width: 46px; padding: 0; justify-content: center; }
.btn-small { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); }
.btn-small:hover { box-shadow: 3px 3px 0 var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.chip svg { width: 18px; height: 18px; stroke-width: 2.6; }
.chip:hover { transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] svg { stroke: #fff; }

/* ---------- mise en page ---------- */
/* grille : colonnes outils | toile | panneau
   lignes  : place pour Miffy & Gloomy | toile | palette
   - les outils sont centrés verticalement sur la ligne de la toile ;
   - le panneau couvre les trois lignes et défile à l'intérieur, la page reste fixe. */
.studio {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--tools-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: var(--peek-space) auto auto;
  column-gap: var(--col-gap);
  padding: 10px 24px 28px;
  align-items: start;
  /* largeur de la toile : dictée par la hauteur d'écran disponible (ratio 16/10) */
  --frame-w: calc((100vh - var(--frame-free)) * 1.6);
}

/* ---------- outils ---------- */
.tools {
  grid-column: 1; grid-row: 2;
  align-self: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px;
}
.tool {
  position: relative;
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .12s;
}
.tool svg { width: 34px; height: 34px; overflow: visible; }
.tool:hover { transform: rotate(-4deg) scale(1.05); }
.tool.active {
  background: var(--tc);
  box-shadow: 3px 3px 0 var(--ink);
  transform: translate(-2px, -2px);
}
.tool.active svg { animation: boing .45s ease; }
@keyframes boing { 30% { transform: scale(1.25) rotate(-8deg); } 60% { transform: scale(.92) rotate(4deg); } }
.tool::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%;
  transform: translateY(-50%) scale(.9);
  white-space: nowrap;
  background: var(--ink); color: #fff;
  padding: 6px 10px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .12s, transform .12s;
  z-index: 10;
}
.tool:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }
.tools-sep { height: 3px; border-radius: 3px; background: var(--ink); opacity: .15; margin: 2px 6px; }

/* ---------- toile ---------- */
/* la toile et la palette sont placées directement dans la grille de l'atelier */
.stage { display: contents; }

.frame-holder {
  grid-column: 2; grid-row: 2;
  justify-self: center; align-self: center;
  position: relative;
  width: min(100%, var(--frame-w));
  min-width: 280px;
}
.frame { position: relative; z-index: 1; padding: 10px; border-radius: 28px; }

/* Miffy et Gloomy Bear qui dépassent derrière la toile */
.peek {
  position: absolute; z-index: 0;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(3px 3px 0 rgba(42, 37, 35, .18));
}
.peek-miffy {
  width: 139px;               /* image 500×612 → 170 px de haut */
  left: 40px; top: -118px;    /* le visage dépasse, le corps est caché */
  transform-origin: 45% 100%;
  animation: sway 5s ease-in-out infinite;
}
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(3deg); } }
.peek-gloomy {
  width: 190px;               /* image 500×500 */
  right: 46px; top: -110px;
  transform-origin: 50% 100%;
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.frame-holder:hover .peek-gloomy { transform: translateY(-10px) rotate(-4deg); }

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  overflow: hidden;
  border: 2.5px solid var(--ink);
  touch-action: none;
  /* damier visible si le fond est transparent */
  background:
    conic-gradient(#f3ece6 25%, #fff 0 50%, #f3ece6 0 75%, #fff 0) 0 0 / 28px 28px;
}
.canvas-wrap canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#overlayCanvas { cursor: none; }

.loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  font-size: 22px; font-weight: 600;
  z-index: 5;
}
.loading span { animation: hop 1s ease-in-out infinite; }

/* ---------- palette ---------- */
.palette {
  grid-column: 2; grid-row: 3;
  justify-self: center;
  margin-top: 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  padding: 12px 16px;
  /* jamais plus étroite qu'une ligne de couleurs : sinon elle passerait sur
     deux lignes et pousserait la page sous le bord de l'écran */
  width: min(100%, max(var(--frame-w), 860px));
  min-width: 280px;
  container-type: inline-size;
}
/* colonne trop étroite : pastilles plus petites pour rester sur une ligne
   (largeurs mesurées à l'intérieur de la palette) */
@container (max-width: 815px) {
  .palette .swatches { gap: 6px; }
  .palette .swatch { width: 28px; height: 28px; }
}
@container (max-width: 700px) {
  .palette .swatches { gap: 5px; }
  .palette .swatch { width: 24px; height: 24px; }
  .palette .rainbow-label { display: none; }
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: var(--line) solid var(--ink);
  background: var(--c);
  cursor: pointer;
  padding: 0;
  transition: transform .12s, box-shadow .12s;
}
.swatch:hover { transform: scale(1.12) rotate(-6deg); }
.swatch.active { transform: translateY(-4px) scale(1.12); box-shadow: 0 4px 0 var(--ink); }
.palette-extra { display: flex; gap: 10px; align-items: center; }

.custom-color { position: relative; width: 38px; height: 38px; cursor: pointer; }
.custom-color input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.custom-dot {
  display: block; width: 100%; height: 100%;
  border-radius: 50%; border: var(--line) solid var(--ink);
  background: conic-gradient(#E8412F, #F59A23, #FFCB3D, #3E9B5C, #9FD3F5, #2C6BC4, #C3B1F0, #F48FB1, #E8412F);
  pointer-events: none;
}
.custom-color.active .custom-dot { box-shadow: 0 4px 0 var(--ink); transform: translateY(-4px); }
.rainbow-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor;
  background: conic-gradient(#ffb3c7, #ffd59e, #fff3a0, #b8f0c8, #a8d8ff, #d4c2ff, #ffb3c7);
}

/* ---------- panneau ---------- */
.panel {
  grid-column: 3; grid-row: 1 / 4;
  align-self: stretch;
  display: flex; flex-direction: column; gap: 18px;
  /* défilement interne : le panneau prend la hauteur de l'atelier sans l'agrandir */
  contain: size;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* place pour les ombres des cartes et la barre de défilement */
  padding: 0 14px 8px 0;
  margin-right: -14px;
  scrollbar-width: thin;
  scrollbar-color: var(--pink) transparent;
}
.panel > * { flex-shrink: 0; }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--pink); border-radius: 8px; border: 2px solid var(--cream); }
.panel::-webkit-scrollbar-track { background: transparent; }
.pcard { padding: 16px 16px 18px; }
.pcard h2 {
  margin: 0 0 12px;
  font-size: 19px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.pcard h2::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: var(--yellow); flex: none;
}
.panel .pcard:nth-child(2) h2::before { background: var(--pink); }
.panel .pcard:nth-child(3) h2::before { background: var(--sky); }
.panel .pcard:nth-child(4) h2::before { background: var(--mint); }
.panel .pcard:nth-child(5) h2::before { background: var(--lav); }
.pcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.pcard-head h2 { margin: 0; }

.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat-thumb {
  position: relative;
  aspect-ratio: 1;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background: #fff;
  padding: 4px;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.cat-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; filter: drop-shadow(0 2px 0 rgba(42,37,35,.15)); }
.cat-thumb:hover { transform: rotate(-3deg) scale(1.04); }
.cat-thumb.on { background: var(--pink-l); box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); }
.cat-thumb.on::after {
  content: "♥";
  position: absolute; top: -9px; right: -9px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red); color: #fff;
  border: 2.5px solid var(--ink);
  font-size: 12px; line-height: 1;
}
.cat-thumb .remove {
  position: absolute; bottom: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: #fff;
  font-size: 13px; font-weight: 700; line-height: 1;
  display: none; place-items: center; padding: 0; cursor: pointer;
}
.cat-thumb:hover .remove { display: grid; }
.cat-add {
  aspect-ratio: 1;
  border: var(--line) dashed var(--ink);
  border-radius: 16px;
  background: transparent;
  display: grid; place-items: center; align-content: center; gap: 2px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.cat-add b { font-size: 26px; line-height: 1; }
.cat-add:hover { background: var(--pink-l); }

.hint { margin: 12px 0 0; font-size: 13px; line-height: 1.4; opacity: .75; }

.row { margin-top: 12px; }
.row:first-of-type { margin-top: 0; }
.row label { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.row output {
  font-size: 12px; font-weight: 600;
  background: var(--ink); color: #fff;
  border-radius: 999px; padding: 1px 8px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink) var(--p, 50%), #fff var(--p, 50%));
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
input[type="range"]:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.seg {
  display: flex;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.seg button {
  flex: 1;
  border: 0; background: transparent;
  padding: 7px 4px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.seg button + button { border-left: 2.5px solid var(--ink); }
.seg button:hover { background: var(--pink-l); }
.seg button.on { background: var(--yellow); }
.seg-wide button { padding: 9px 4px; font-size: 14px; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.toggles:not(:has(.chip:not([hidden]))) { display: none; }
#flattenAllBtn { margin-top: 12px; width: 100%; justify-content: center; }

.sticker-card { background: #FFF6D8; }
.sticker-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-opt {
  aspect-ratio: 1;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  padding: 0; overflow: hidden;
  background: #fff center / cover no-repeat;
  cursor: pointer;
  transition: transform .12s;
}
.bg-opt:hover { transform: rotate(-4deg); }
.bg-opt.on { box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); outline: 3px solid var(--pink); outline-offset: 2px; }

/* ---------- modale & toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(42, 37, 35, .35);
  padding: 16px;
}
.modal-box {
  width: min(360px, 100%);
  padding: 22px 22px 20px;
  text-align: center;
  animation: pop .25s cubic-bezier(.3, 1.6, .5, 1);
}
.modal-cat { width: 80px; height: 72px; stroke-width: 0; }
.modal-box p { font-size: 22px; font-weight: 700; margin: 8px 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  transform: translate(-50%, calc(100% + 60px));
  opacity: 0; visibility: hidden;
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--pink);
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), opacity .2s, visibility 0s .3s;
  pointer-events: none;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1; visibility: visible;
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), opacity .2s;
}

/* ---------- responsive ---------- */
/* logo un peu plus petit pour laisser la place à la barre d'export */
@media (max-width: 1560px) {
  .logo { font-size: 36px; }
  .mascot { width: 54px; height: 54px; }
  .tagline { font-size: 13px; }
  .io-bar { gap: 8px; }
  .seg-format button { padding: 0 9px; }
  .io-bar .btn { padding: 0 13px; }
}
/* plus assez de place sur une ligne : la barre passe dessous, toujours centrée sur la toile */
@media (max-width: 1340px) {
  :root { --frame-free: 410px; }
  .topbar .io-bar { grid-row: 2; }
}
/* écran peu haut : barre d'outils plus compacte pour tenir à côté de la toile */
@media (max-height: 820px) and (min-width: 721px) {
  :root { --tools-w: 74px; }
  .tools { gap: 7px; padding: 10px; }
  .tool { width: 48px; height: 48px; border-radius: 15px; }
  .tool svg { width: 28px; height: 28px; }
}
@media (max-height: 700px) and (min-width: 721px) {
  :root { --tools-w: 66px; }
  .tools { gap: 5px; }
  .tool { width: 40px; height: 40px; border-radius: 13px; }
  .tool svg { width: 24px; height: 24px; }
}
/* panneau sous la toile : la page défile normalement */
@media (max-width: 1100px) {
  .studio, .topbar { grid-template-columns: var(--tools-w) minmax(0, 1fr); }
  .studio { grid-template-rows: var(--peek-space) auto auto auto; }
  .topbar .actions { grid-column: 2; }
  .panel {
    grid-column: 1 / -1; grid-row: 4; align-self: start;
    contain: none; overflow: visible;
    padding: 0; margin: 28px 0 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start;
  }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 16px 4px; grid-template-columns: minmax(0, 1fr); }
  .topbar .brand { grid-row: 1; grid-column: 1; justify-self: center; }
  .topbar .io-bar { grid-row: 2; grid-column: 1; }
  .topbar .actions { grid-row: 3; grid-column: 1; justify-self: center; }
  .logo { font-size: 34px; }
  .studio { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; padding: 8px 16px 24px; row-gap: 16px; }
  .tools, .frame-holder, .palette, .panel { grid-column: 1; grid-row: auto; }
  .tools { align-self: start; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .palette, .panel { margin-top: 0; }
  .tool { width: 50px; height: 50px; }
  .tool svg { width: 30px; height: 30px; }
  .tool::after { display: none; }
  .tools-sep { width: 3px; height: auto; margin: 6px 2px; }
  .frame-holder, .palette { width: 100%; min-width: 0; }
  .frame-holder { margin-top: 80px; }
  .peek-miffy { left: 18px; width: 100px; top: -85px; }
  .peek-gloomy { right: 16px; width: 136px; top: -79px; }
  .io-bar { gap: 8px; padding: 6px; }
  .seg-format button { padding: 0 8px; }
  .btn span { display: none; }
  .btn { padding: 0 12px; }
}

/* ---------- impression : uniquement le dessin ---------- */
#printArea { display: none; }
@media print {
  @page { size: landscape; margin: 10mm; }
  html, body { background: #fff !important; height: auto; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: flex !important; justify-content: center; align-items: center; width: 100%; }
  #printImg {
    display: block;
    width: 100%; height: auto;
    max-height: 185mm;
    object-fit: contain;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}