/* The mascot pixel editor (assets/js/mascot-editor.js), on admin's Mascot card and
   the public designer (/mascot-designer). The grid is 40x36 cells of 12px,
   scaled down to fit; every colour is a theme or --sprite-* token. */
.mse{font-family:var(--font-ui);color:var(--ink)}
.mse-head{display:flex;flex-wrap:wrap;gap:16px;align-items:flex-end;margin-bottom:12px}
.mse-head label{display:block;font:700 .82rem/1.3 var(--font-ui);color:var(--navy);margin-bottom:4px}
.mse-head input[type=text]{padding:8px 10px;border:1.5px solid var(--field-border);border-radius:8px;font:400 .95rem var(--font-ui);min-width:220px;max-width:100%}
.mse-modes{display:flex;gap:14px;flex-wrap:wrap}
.mse-modes label{display:flex;gap:6px;align-items:center;font-weight:600;margin:0;min-height:32px}
.mse-frames{display:flex;flex-wrap:wrap;gap:4px;border-bottom:1.5px solid var(--line);margin-bottom:6px}
.mse-frame{position:relative;padding:8px 12px;border:1.5px solid transparent;border-bottom:0;border-radius:8px 8px 0 0;background:none;
  color:var(--navy);font:600 .85rem/1.2 var(--font-ui);cursor:pointer;min-height:36px}
.mse-frame[aria-selected="true"]{border-color:var(--line);background:var(--sprite-white);margin-bottom:-1.5px}
.mse-frame.has-own .mse-own{display:inline-block;width:7px;height:7px;margin-left:6px;border-radius:50%;background:var(--blue-dark);vertical-align:middle}
.mse-hint{margin:4px 0 10px;font:400 .82rem/1.45 var(--font-ui);color:var(--muted)}
.mse-main{display:flex;flex-wrap:wrap;gap:16px;align-items:flex-start}
.mse-left{flex:0 1 480px;min-width:0;width:100%}
.mse-grid{display:block;width:100%;max-width:480px;height:auto;aspect-ratio:40 / 36;border:1.5px solid var(--line);border-radius:6px;
  cursor:crosshair;touch-action:none;image-rendering:crisp-edges;image-rendering:pixelated}
.mse-grid:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}
.mse-pos{min-height:1.3em;margin:4px 0 0;font:400 .8rem var(--font-ui);color:var(--muted)}
.mse-side{flex:1 1 260px;display:flex;flex-direction:column;gap:12px;min-width:0}
.mse-tools{display:flex;flex-wrap:wrap;gap:6px}
.mse-tools [aria-pressed="true"]{background:var(--navy);color:var(--sprite-white)}
.mse-ghost{display:flex;gap:6px;align-items:center;font:400 .85rem var(--font-ui)}
.mse-palette{display:flex;flex-wrap:wrap;gap:5px}
.mse-swatch{width:32px;height:32px;padding:3px;border:1.5px solid var(--line);border-radius:6px;background:var(--sprite-white);cursor:pointer}
.mse-swatch span{display:block;width:100%;height:100%;border-radius:3px}
.mse-swatch[aria-checked="true"]{border-color:var(--navy);box-shadow:0 0 0 2px var(--navy)}
.mse-swatch:focus-visible,.mse-frame:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}
.mse-colour{margin:0;font:400 .82rem var(--font-ui);color:var(--muted)}
.mse-parts{margin:0;padding:10px 12px;border:1.5px solid var(--line);border-radius:10px;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
.mse-parts legend{padding:0 4px;font:700 .85rem var(--font-ui);color:var(--navy)}
.mse-parts .mse-hint{grid-column:1 / -1;margin:0}
.mse-parts label{display:flex;flex-direction:column;gap:3px;font:600 .8rem var(--font-ui);color:var(--navy)}
.mse-parts select{padding:6px;border:1.5px solid var(--field-border);border-radius:6px;font:400 .85rem var(--font-ui)}
.mse-parts[hidden]{display:none}
.mse-preview{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.mse-stage{width:160px;height:144px;border:1.5px solid var(--line);border-radius:10px;background:var(--band);image-rendering:crisp-edges;image-rendering:pixelated}

/* Zoom, the colour panel and their colours (migration 056: any colour, him or her). */
.mse-grid.is-pan{cursor:grab}
.mse-zoom-level{min-width:44px;text-align:center;font:700 .8rem var(--font-ui);color:var(--navy)}
.mse-palette-actions,.mse-preview-actions{display:flex;flex-wrap:wrap;gap:6px}
.mse-chip{display:inline-block;width:28px;height:28px;border:1.5px solid var(--line);border-radius:6px;flex:none}
.mse-part{display:flex;align-items:center;gap:8px;min-height:40px;padding:6px 8px;border:1.5px solid var(--line);border-radius:8px;
  background:var(--sprite-white);color:var(--navy);font:600 .8rem var(--font-ui);cursor:pointer;text-align:left}
.mse-part .mse-chip{width:22px;height:22px}
.mse-part:not(.is-set) .mse-chip{background-image:linear-gradient(45deg,transparent 45%,var(--line) 45%,var(--line) 55%,transparent 55%)}
.mse-part[aria-pressed="true"]{border-color:var(--navy);box-shadow:0 0 0 2px var(--navy)}
.mse-part:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}

/* The Custom colour window (a <dialog>): shade square, hue bar, new against before,
   HEX / RGB / HSB, the colour squares, Cancel / Apply. */
.mse-cw{margin:auto;inset:0;width:min(330px,calc(100vw - 24px));max-height:calc(100vh - 24px);overflow:auto;padding:16px;border:0;border-radius:14px;
  background:var(--sprite-white);color:var(--navy);box-shadow:0 18px 50px rgba(var(--navy-rgb),.35);font-family:var(--font-ui)}
.mse-cw::backdrop{background:rgba(var(--navy-rgb),.35)}
.mse-cw-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.mse-cw-head h3{margin:0;font:700 1.1rem var(--font-ui);color:var(--navy)}
.mse-cw-x{width:36px;height:36px;border:0;border-radius:8px;background:none;color:var(--navy);font:400 1.6rem/1 var(--font-ui);cursor:pointer}
.mse-cw-sv{display:block;width:100%;height:auto;aspect-ratio:264 / 150;border-radius:8px;cursor:crosshair;touch-action:none}
.mse-cw-hue{display:block;width:100%;height:auto;aspect-ratio:264 / 18;margin-top:10px;cursor:pointer;touch-action:none}
.mse-cw-sv:focus-visible,.mse-cw-hue:focus-visible,.mse-cw-x:focus-visible,.mse-cw-reset:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}
.mse-cw-compare{display:flex;height:14px;margin:12px 18px;border-radius:7px;overflow:hidden;border:1px solid var(--line)}
.mse-cw-compare span{flex:1}
.mse-cw-squares{display:flex;flex-direction:column;gap:4px;margin:4px 0 12px}
.mse-cw-row{display:flex;gap:4px}
.mse-cw-row .mse-square{flex:1;width:auto;height:auto;aspect-ratio:1;min-width:24px;padding:2px}
.mse-square{width:32px;height:32px;padding:3px;border:1.5px solid var(--line);border-radius:6px;background:var(--sprite-white);cursor:pointer}
.mse-square span{display:block;width:100%;height:100%;border-radius:3px}
.mse-square[aria-pressed="true"]{border-color:var(--navy);box-shadow:0 0 0 2px var(--navy)}
.mse-square:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}
.mse-cw-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.mse-cw-reset{flex-basis:100%;margin:0 0 4px;text-align:left;padding:4px 2px;border:0;background:none;color:var(--blue-dark);font:600 .82rem var(--font-ui);text-decoration:underline;cursor:pointer}
.mse-cw-reset[hidden]{display:none}

/* The dock under the grid: the colours, then the tools (icons, with their names
   beside them on a wider screen). */
.mse button{touch-action:manipulation}
.mse-dock{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.mse-dock-tools{display:flex;flex-wrap:wrap;align-items:center;gap:4px}
.mse-dock-gap{flex:0 0 8px}
.mse-tool{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:44px;min-height:44px;padding:0 10px;
  border:1.5px solid var(--line);border-radius:10px;background:var(--sprite-white);color:var(--navy);font:600 .82rem var(--font-ui);cursor:pointer}
.mse-tool[aria-pressed="true"]{background:var(--navy);border-color:var(--navy);color:var(--sprite-white)}
.mse-tool:focus-visible{outline:3px solid var(--blue-dark);outline-offset:2px}
.mse-tap,.mse-fullbar{display:none}
.mse-tool-tiny{display:none}

/* A phone: the grid scrolls the page until tapped; tapping opens full screen. */
@media (max-width:767.98px){
  .mse:not(.is-full) .mse-grid{touch-action:pan-x pan-y;cursor:pointer}
  .mse-tap{display:block;width:100%;margin-top:6px;padding:12px;border:1.5px dashed var(--blue-dark);border-radius:10px;
    background:var(--band);color:var(--blue-dark);font:700 .95rem var(--font-ui);cursor:pointer}
  .mse:not(.is-full) .mse-dock{display:none}
  .mse-tool{padding:2px 0 3px;flex-direction:column;gap:1px}
  .mse-tool-label{display:none}
  /* Little descriptions under the icons (Tré, 2026-10-17). */
  .mse-tool-tiny{display:block;font:600 .56rem/1 var(--font-ui);letter-spacing:.01em;white-space:nowrap}
  .mse-tool svg{width:18px;height:18px}
  .mse-palette{flex-wrap:nowrap;overflow-x:auto;padding:2px 2px 6px;scrollbar-width:thin;-webkit-overflow-scrolling:touch}
  .mse-palette .mse-swatch{flex:none;width:40px;height:40px}
  .mse-dock-tools{flex-wrap:nowrap;overflow-x:auto;padding-bottom:2px}
  .mse-dock-tools .mse-tool{flex:none}
}

/* Full screen drawing: only the poses, the grid and the dock. */
.mse.is-full{position:fixed;inset:0;z-index:80;display:flex;flex-direction:column;gap:6px;margin:0;
  padding:8px 10px calc(8px + env(safe-area-inset-bottom));background:var(--sprite-white);overflow-x:hidden;overflow-y:auto}
.mse.is-full .mse-fullbar{display:flex;align-items:center;justify-content:space-between;gap:10px}
.mse-fullbar-hint{font:400 .8rem var(--font-ui);color:var(--muted)}
.mse.is-full .mse-head,.mse.is-full .mse-hint,.mse.is-full .mse-side,.mse.is-full .mse-pos,.mse.is-full .mse-tap{display:none}
.mse.is-full .mse-frames{flex-wrap:nowrap;overflow-x:auto;flex:none}
.mse.is-full .mse-frame{flex:none;min-height:40px}
.mse.is-full .mse-main{flex:1;min-height:0;display:flex;flex-direction:column}
.mse.is-full .mse-left{flex:1;min-height:0;display:flex;flex-direction:column;max-width:none}
.mse.is-full .mse-grid{flex:none;width:min(100%,calc((100dvh - 420px) * 40 / 36));min-width:240px;max-width:none;margin:0 auto;touch-action:none}
/* Under the tools, in full screen: Their colours (each opens the colour window). */
.mse-dock-parts{display:none}
.mse.is-full .mse-dock-parts{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px}
.mse.is-full .mse-dock-parts .mse-part{min-height:48px;font-size:.9rem}
.mse.is-full .mse-dock-parts .mse-chip{width:26px;height:26px}
@media (max-width:767.98px){
  .mse.is-full .mse-grid{width:100%}
}
html.mse-locked,html.mse-locked body{overflow:hidden;overscroll-behavior:none}
