/* Sprite editor layout: controls on the left, a sticky preview + action column on the right; on phones a compact
   dock (token, dimensions, main button) stays on screen. Shared by play.cartosmith.app/sprite.html and
   sprite.cartosmith.app (identical file in both trees). Builds on the tokens in site.css; light and dark both follow. */
:root{--gold-text:#8a4311;--chk-a:#ece6da;--chk-b:#fffdf8}
/* dark mode: a warm mid-grey checker, so transparency never looks like the dark backdrops (#1d2736 etc.) */
.checker,.pv-box,.dock-thumb{background:conic-gradient(var(--chk-a) 25%,var(--chk-b) 0 50%,var(--chk-a) 0 75%,var(--chk-b) 0) 0 0/16px 16px}

.intro{max-width:62ch;margin:0 0 4px}
.editor .btn--quiet,.editor a:not(.btn){color:var(--gold-text)}
.editor .btn--quiet{border-color:var(--gold-text)}
.editor h3{margin:0 0 12px}
.editor .opt{font-weight:400;letter-spacing:0}

/* ---- page grid: controls | sticky preview column ---- */
.ed-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-items:start}
.ed-main,.ed-side{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-content:start;min-width:0}
.ed-main>.card+.card,.ed-side>.card+.card{margin-top:0}
/* two columns from tablet width up: the preview column sticks while the controls scroll */
@media(min-width:700px){
  .ed-grid{grid-template-columns:minmax(0,1fr) 260px;gap:18px}
  .ed-side{position:sticky;top:12px;max-height:calc(100vh - 24px);overflow-y:auto;overscroll-behavior:contain;gap:12px;padding:2px}
  .ed-side .card{padding:16px}
  /* room below the last controls so the sticky column is never pushed off the top while they are in view */
  .ed-main{padding-bottom:max(0px,calc(var(--side-h,0px) - 50vh + 40px))}
  .dock{display:none!important}
}
@media(min-width:900px){.ed-grid{grid-template-columns:minmax(0,1fr) 340px;gap:24px}}
@media(min-width:1200px){.ed-grid{grid-template-columns:minmax(0,1fr) 370px}}

/* ---- top: reopen + modes ---- */
.ed-top{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;margin:14px 0 0}
.ed-top .btn{min-height:44px}
.ed-top-note{flex:1 1 260px;margin:0;max-width:60ch}
.editor .modes{margin:14px 0 0}
body .editor .modes button[aria-selected=true]{box-shadow:inset 0 0 0 1px var(--gold),inset 0 -3px 0 var(--gold)}
.editor .modes button[aria-selected=true]::before{content:"✓ ";font-weight:700}

/* ---- selected vs action: selected things get a check, a doubled gold edge and a pressed look ---- */
body .editor .sc-tools button[aria-pressed=true],body .editor .seg button[aria-checked=true],body .editor .seg button[aria-pressed=true]{border-color:var(--gold);box-shadow:inset 0 0 0 1px var(--gold),inset 0 2px 5px rgba(0,0,0,.18);font-weight:700;color:var(--cream)}
.editor .sc-tools>button[aria-pressed=true]::before,.editor .seg:not(.sws) button[aria-checked=true]::before,.editor .seg button[aria-pressed=true]::before{content:"✓";margin-right:5px;font-weight:700}
body .editor .seg button[aria-pressed=false]{font-weight:500}
.sw,.seg.sws button{position:relative}
.sw[aria-pressed=true]::after,.seg.sws button[aria-checked=true]::after{content:"✓";position:absolute;inset:0;display:grid;place-items:center;font:700 15px/1 var(--sans);color:#fff;text-shadow:0 0 2px #000,0 0 4px #000}
body .editor .sw[aria-pressed=true],body .editor .seg.sws button[aria-checked=true]{border:3px solid var(--cream);box-shadow:0 0 0 2px var(--gold),0 0 0 4px var(--ink-950)}
.pg-val{font-weight:500;color:var(--text);letter-spacing:0}

/* ---- builder ---- */
.sc{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}
.sc-presets{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:8px;margin:0 0 12px}
.sc-preset{display:flex;align-items:center;gap:8px;min-height:52px;padding:6px 10px;border-radius:var(--radius);border:1px solid var(--line-soft);background:var(--ink-950);color:var(--text);font:600 15px var(--sans);cursor:pointer;text-align:left}
.sc-preset:hover{border-color:var(--gold)}
.sc-preset canvas{width:38px;height:38px;image-rendering:pixelated;border-radius:50%;flex:none}
.sc-build-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 0 6px}
.sc-build-actions .btn.small{min-height:44px;padding:8px 14px}
#sc-random{font-size:15px}
.sc-hist{display:flex;gap:8px;margin-left:auto}
@media(max-width:520px){.sc-hist{margin-left:0}}

/* ---- collapsible panels (native details: keyboard operable) ---- */
.sc-panel{border:1px solid var(--line-soft);border-radius:12px;background:var(--ink-800)}
body:not(.play) .sc-panel{border-color:rgba(166,83,22,.22)}
.sc-panel>summary{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 12px;min-height:56px;padding:14px 64px 14px 18px;cursor:pointer;list-style:none;position:relative;border-radius:12px}
.sc-panel>summary::-webkit-details-marker{display:none}
.sc-panel>summary::after{content:"Open";position:absolute;right:16px;top:50%;transform:translateY(-50%);font:600 13px var(--sans);color:var(--gold-text)}
.sc-panel[open]>summary::after{content:"Close"}
.sc-panel>summary:hover .sc-sum-t{text-decoration:underline}
.sc-pixels>summary .sc-sum-t::before{content:"✎ ";color:var(--gold-text)}
.sc-sum-t{font:700 17px var(--serif);color:var(--cream)}
.sc-sum-d{font-size:13px;color:var(--muted)}
.sc-panel-body{padding:0 18px 18px}

/* ---- builder tabs (0.9.54): one group of parts at a time, so a phone page stays short ---- */
.sc-tabs{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;margin:14px 0 0;padding:4px;border-radius:12px;background:rgba(17,27,34,.05);border:1px solid var(--line-soft)}
@media(max-width:560px){.sc-tabs{grid-template-columns:repeat(3,minmax(0,1fr))}}
.sc-tabs button{min-height:44px;padding:6px 4px;border:1px solid transparent;border-radius:9px;background:transparent;color:var(--text);font:600 15px var(--sans);cursor:pointer}
.sc-tabs button:hover{border-color:var(--gold)}
body .editor .sc-tabs button[aria-selected=true]{background:var(--ink-950);border-color:var(--gold);color:var(--cream);box-shadow:inset 0 -3px 0 var(--gold)}
.sc-parts{margin-top:14px}
.sc-tp{display:grid;gap:16px}
.sc-tabnote{margin:0;max-width:60ch}
.sc-sec-note{margin:0;max-width:60ch}
.pg .label{margin-bottom:6px}
.seg.sws button{width:44px;height:44px;min-height:44px}
.seg button{min-height:44px}
/* peoples: a picture of your character as each one */
.editor .seg.sc-races{display:grid;grid-template-columns:repeat(auto-fill,minmax(84px,1fr));gap:6px}
.editor .sc-races button{display:grid;justify-items:center;gap:2px;padding:6px 2px;text-transform:none;font-weight:600;font-size:13px}
.editor .sc-races button::before{display:none}
.sc-races canvas{width:48px;height:48px;image-rendering:pixelated;border-radius:50%}
@media(max-width:560px){.editor .seg.sc-races{grid-template-columns:repeat(4,minmax(0,1fr))}.sc-races canvas{width:42px;height:42px}.editor .sc-races button{font-size:12px}}
/* which colour the wheel changes (Outfit tab) */
.editor .sc-targets{margin-bottom:10px}
.editor .sc-targets button{display:inline-flex;align-items:center;gap:8px;text-transform:none}
.editor .sc-targets button::before{display:none}
.tchip{width:20px;height:20px;border-radius:50%;border:1px solid rgba(17,27,34,.35);flex:none}
.tchip.none,.cm-chip.none{background:repeating-linear-gradient(45deg,#c9c1b2 0 3px,#fffdf8 3px 6px)}
.sc-colour-l{font-size:14px;color:var(--text)}
/* light: a 3 x 3 pad of directions and an Off button */
.sc-lightrow{display:flex;flex-wrap:wrap;align-items:center;gap:12px}
.editor .seg.sc-lightpad{display:grid;grid-template-columns:repeat(3,52px);gap:6px}
.editor .sc-lightpad button{width:52px;height:52px;padding:0;font:700 20px/1 var(--sans)}
.editor .sc-lightpad button::before{display:none}
body .editor .sc-lightpad button[aria-checked=true]{background:#f2c94c;color:#111b22}
.editor .sc-lightoff button{text-transform:none}
.sc-range{width:100%;max-width:360px;height:36px;accent-color:var(--gold)}

/* ---- colour mixer: wheel + brightness + code, then quick picks ---- */
.cm{display:grid;gap:12px}
.cm-row{display:flex;flex-wrap:wrap;align-items:center;gap:14px 18px}
.cm-wheelbox{position:relative;width:168px;height:168px;flex:none}
.cm-wheel{width:100%;height:100%;display:block;border-radius:50%;touch-action:none;cursor:crosshair;box-shadow:0 0 0 1px rgba(17,27,34,.25)}
.cm-wheel:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
.cm-dot{position:absolute;width:22px;height:22px;margin:-11px 0 0 -11px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 1px #000,0 1px 4px rgba(0,0,0,.5);pointer-events:none}
.cm-side{display:grid;gap:4px;flex:1 1 150px;min-width:140px;max-width:260px}
.cm-now{display:flex;align-items:center;gap:10px;margin-bottom:6px;font:500 14px/1.3 var(--sans);color:var(--text)}
.cm-chip{width:40px;height:40px;border-radius:8px;border:2px solid rgba(17,27,34,.3);flex:none}
.cm-l{margin:4px 0 0;font-size:12px}
.cm-v{-webkit-appearance:none;appearance:none;width:100%;height:32px;margin:0;border-radius:16px;background:linear-gradient(90deg,#000,var(--cm-full,#fff));border:1px solid rgba(17,27,34,.3);cursor:pointer}
.cm-v::-webkit-slider-thumb{-webkit-appearance:none;width:30px;height:30px;border-radius:50%;background:#fff;border:3px solid #111b22;box-shadow:0 1px 4px rgba(0,0,0,.4)}
.cm-v::-moz-range-thumb{width:26px;height:26px;border-radius:50%;background:#fff;border:3px solid #111b22}
.cm-hex{width:110px;min-height:40px;font:600 15px ui-monospace,Menlo,Consolas,monospace;text-transform:lowercase}
.cm-quick{display:flex;flex-wrap:wrap;gap:6px}
.editor .cm-quick .sw{width:40px;height:40px;min-height:40px;padding:0;border-radius:50%;border:2px solid rgba(17,27,34,.28);cursor:pointer}
.cm-quick .sw.none{background:repeating-linear-gradient(45deg,#2a3547 0 4px,#161e2a 4px 8px)}
@media(max-width:400px){.cm-wheelbox{width:150px;height:150px}.cm-side{min-width:0}}

/* ---- pixel editor (0.9.54): Paint-style. Canvas, big tool buttons, line sizes, colours. ---- */
.sc-pixels{container-type:inline-size}
.sc-paint{display:grid;gap:14px;grid-template-columns:minmax(0,1fr)}
.sc-stage{min-width:0}
.editor .sc-view{max-width:480px;margin:0 auto}
.sc-stagebar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:8px;max-width:480px;margin-inline:auto}
.sc-cur{display:inline-flex}
.sc-now-sw{width:44px;height:44px;border-radius:8px;border:3px solid var(--ink-950);box-shadow:0 0 0 1px rgba(17,27,34,.4);flex:none}
.sc-ib,.sc-tg{min-height:44px;min-width:44px;padding:6px 10px;border-radius:var(--radius);border:1px solid var(--line-soft);background:var(--ink-950);color:var(--text);font:500 14px var(--sans);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px}
.sc-ib:disabled{opacity:.4;cursor:default}
.sc-ib:hover:not(:disabled),.sc-tg:hover{border-color:var(--gold)}
body .editor .sc-tg[aria-pressed=true]{border-color:var(--gold);background:#f3e5ca;color:#111b22;font-weight:700;box-shadow:inset 0 0 0 1px var(--gold)}
.editor .sc-zoom{flex-wrap:nowrap;gap:4px}
.editor .sc-zoom button{padding:6px 10px}
.editor .sc-zoom button::before{display:none}
/* tools: a grid of big icon buttons with a short name, like a 1999 paint program */
.sc-toolbox{display:grid;gap:8px;align-content:start}
.editor .sc-tools{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:6px;margin:0}
.editor .sc-tool{display:grid;justify-items:center;align-content:center;gap:2px;min-height:58px;padding:6px 2px;border:2px solid var(--line-soft);border-radius:10px;background:var(--ink-950);color:var(--cream);font:600 12px/1.1 var(--sans);cursor:pointer}
.editor .sc-tool svg{width:26px;height:26px}
.editor .sc-tool:hover{border-color:var(--gold)}
body .editor .sc-tools .sc-tool[aria-pressed=true]{background:#f2c94c;border-color:#111b22;color:#111b22;box-shadow:inset 0 2px 4px rgba(0,0,0,.25)}
.editor .sc-tools>.sc-tool[aria-pressed=true]::before{content:none}
/* line sizes: the dot is the size */
.editor .seg.sc-brushes{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}
.editor .sc-brushes button{display:grid;place-items:center;min-height:44px;padding:0}
.editor .sc-brushes button::before{display:none}
.sc-brushes i{display:block;width:calc(3px + var(--b) * 2.5px);height:calc(3px + var(--b) * 2.5px);background:currentColor;border-radius:2px}
body .editor .sc-brushes button[aria-checked=true]{background:#f2c94c;color:#111b22}
/* colours */
.sc-colours{min-width:0}
.sc-now{display:flex;align-items:center;gap:10px;margin:0 0 10px;font-size:14px}
.sc-now strong{color:var(--cream);font-weight:600}
.editor .sc-palette,.editor .sc-used{display:grid;grid-template-columns:repeat(auto-fill,minmax(34px,1fr));gap:4px;margin:0 0 14px}
.editor .sc-colours .sw{min-height:34px;width:100%;padding:0;border-radius:6px;border:2px solid rgba(17,27,34,.25);cursor:pointer}
.sc-used .small{grid-column:1/-1}
.sc-pixfoot{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
.sc-pixfoot .btn.small{min-height:44px}
.sc-painthint{margin:0}
/* painting only while the pixel editor is open; then (and only then) a finger on the canvas paints instead of scrolling */
.sc .sc-canvaswrap{touch-action:auto}
.sc .sc-canvaswrap canvas{touch-action:pan-x pan-y;cursor:default}
.sc.painting .sc-canvaswrap canvas{touch-action:none;cursor:crosshair}
.sc.painting[data-tool=pick] .sc-canvaswrap canvas{cursor:copy}
/* wide: tools | canvas | colours, side by side like Paint */
@container (min-width:760px){
  .sc-paint{grid-template-columns:132px minmax(0,1fr) minmax(220px,250px);grid-template-areas:"tools stage colours" "foot foot foot" "hint hint hint";align-items:start}
  .sc-toolbox{grid-area:tools}.sc-stage{grid-area:stage}.sc-colours{grid-area:colours}.sc-pixfoot{grid-area:foot}.sc-painthint{grid-area:hint}
  .editor .sc-tools{grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor .seg.sc-brushes{grid-template-columns:repeat(2,minmax(0,1fr))}
  .sc-colours .cm-wheelbox{width:150px;height:150px}
}
@container (min-width:520px) and (max-width:759px){
  .sc-paint{grid-template-columns:120px minmax(0,1fr);grid-template-areas:"tools stage" "colours colours" "foot foot" "hint hint"}
  .sc-toolbox{grid-area:tools}.sc-stage{grid-area:stage}.sc-colours{grid-area:colours}.sc-pixfoot{grid-area:foot}.sc-painthint{grid-area:hint}
  .editor .sc-tools{grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor .seg.sc-brushes{grid-template-columns:repeat(2,minmax(0,1fr))}
}
/* phones: the canvas stays on screen (sticky) while you scroll to tools and colours */
@container (max-width:519px){
  .sc-stage{position:sticky;top:0;z-index:6;margin:0 -14px;padding:8px 14px;background:var(--ink-800);box-shadow:0 10px 14px -12px rgba(0,0,0,.45)}
  .editor .sc-view{max-width:min(100%,38vh)}
  .sc-stagebar{max-width:none;gap:4px;flex-wrap:nowrap;justify-content:center}
  .sc-stagebar .sc-tg,.sc-stagebar .sc-ib{min-width:40px;min-height:40px;padding:4px 6px;font-size:18px}
  .sc-stagebar .sc-tgl{display:none}
  .editor .sc-zoom button{min-height:40px;padding:4px 7px}
  .sc-now-sw{width:40px;height:40px}
  .editor .sc-tool span{font-size:10.5px}
  .editor .sc-tool{min-height:54px;padding:4px 0}
}
@media(max-width:699px){.sc-panel-body{padding:0 14px 16px}}

/* ---- own image ---- */
.im-fit{border:0;padding:0;margin:16px 0 0}

/* ---- download options ---- */
.xchoice{border:0;padding:0;margin:0 0 14px;display:grid;gap:8px}
.xchoice legend{padding:0;margin-bottom:8px}
.xc{display:grid;grid-template-columns:auto 1fr;column-gap:10px;align-items:center;min-height:52px;margin:0;padding:8px 12px;border:1px solid var(--line-soft);border-radius:var(--radius);background:var(--ink-950);cursor:pointer;letter-spacing:0}
.xc input{width:20px;height:20px;margin:0;accent-color:var(--gold);grid-row:span 2}
.xc-t{font:600 15px var(--sans);color:var(--cream)}
.xc-d{grid-column:2;font:400 13px/1.35 var(--sans);color:var(--muted)}
.xc:has(input:checked){border-color:var(--gold);box-shadow:inset 0 0 0 1px var(--gold)}
.xc:has(input:checked) .xc-t::after{content:" ✓";color:var(--gold-text)}
.xc:has(input:focus-visible){outline:2px solid var(--gold);outline-offset:2px}
.xc.off{opacity:.6;cursor:not-allowed}
.xmore>summary{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;min-height:44px;padding:4px 2px;cursor:pointer;font:600 15px var(--sans);color:var(--gold-text);list-style:none}
.xmore>summary::-webkit-details-marker{display:none}
.xmore>summary::before{content:"▸";display:inline-block;transition:transform .15s}
.xmore[open]>summary::before{transform:rotate(90deg)}
.xmore-d{font-weight:500;color:var(--muted)}
.xmore-body{display:grid;gap:8px;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));padding-top:4px}
.export-fine{margin:12px 0 0}

/* ---- preview column ---- */
.pv-fig{margin:0}
/* shown at 256 or 192 CSS px: whole multiples of the 32 and 64 pixel grids, so the pixels stay even */
.pv-box{--pv-max:256;position:relative;box-sizing:content-box;width:256px;max-width:100%;aspect-ratio:1;margin:0 auto;border-radius:6px;outline:1px solid var(--line-soft);display:grid;place-items:center;overflow:hidden}
.pv-box canvas{width:100%;height:100%;display:block;image-rendering:pixelated}
.pv-box .pv-letters{width:70%;height:70%;font-size:clamp(28px,8vw,52px)}
.pv-empty{margin:0;font:600 14px var(--sans);color:var(--muted);background:var(--ink-950);padding:6px 10px;border-radius:6px}
.pv-fig figcaption{text-align:center;margin:8px 0 0}
@media(min-width:700px) and (max-width:899px),(min-width:900px) and (max-height:939px){.pv-box{--pv-max:192;width:192px}}
.export-out{font:500 14px/1.45 var(--sans);color:var(--text);margin:10px 0 0}
.export-warn{margin:8px 0 0;font-weight:600;color:var(--text)}
.export-warn::before{content:"⚠ ";color:var(--yellow)}
.pv-map{margin-top:14px;padding-top:12px;border-top:1px solid var(--line-soft)}
.pv-map-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 8px;margin-bottom:8px}
.editor .map-look{flex-wrap:nowrap}
.pv-map-head .label{margin:0}
.map-look button{min-height:44px;padding:4px 12px;font-size:14px}
.pv-mapcanvas{display:block;width:100%;max-width:264px;margin:0 auto;aspect-ratio:2/1;border-radius:8px;border:1px solid var(--line-soft)}
.pv-map-note{margin:6px 0 0}
.act-row{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px}
.act-dims{font:700 16px var(--sans);color:var(--cream);font-variant-numeric:tabular-nums}
.act-row .btn{min-height:48px;flex:1 1 auto;max-width:100%}
.ed-act{margin-top:12px}
.ed-act .status{margin-top:12px}
.export-more{gap:8px;margin-top:12px}
.export-more:not(:has(> :not([hidden]))){display:none}

/* ---- phone dock: the token, its dimensions and the main button, always in reach ---- */
.dock{position:sticky;bottom:0;z-index:30;display:flex;align-items:center;gap:12px;margin:20px calc(-1 * var(--gutter)) 0;padding:8px var(--gutter);padding-bottom:calc(8px + env(safe-area-inset-bottom));background:var(--ink-950);border-top:1px solid var(--line);box-shadow:0 -10px 24px -16px rgba(0,0,0,.5)}
.dock-thumb{width:76px;height:76px;flex:none;border-radius:10px;border:1px solid var(--line-soft);display:grid;place-items:center;overflow:hidden}
.dock-thumb canvas{width:100%;height:100%;display:block;image-rendering:pixelated}
.dock-thumb.letters{border-radius:50%;background:#397da0;border:3px solid #397da0;color:#fff;font:700 24px var(--sans)}
.dock-info{flex:1;min-width:0;display:grid;gap:2px}
.dock-dims{font:700 15px/1.3 var(--sans);color:var(--cream)}
.bar-msg{font-size:13px;line-height:1.3;color:var(--text);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.bar-msg.ok::before{content:"✓ ";color:var(--green);font-weight:700}
.bar-msg.warn::before,.bar-msg.bad::before{content:"⚠ ";color:var(--yellow);font-weight:700}
.dock .btn{flex:none;min-height:48px;padding:10px 18px}
/* while typing (phone keyboard up) the dock steps aside so it never covers the field */
.editor:has(input[type=text]:focus) .dock{display:none}
@media(max-width:699px){html{scroll-padding-bottom:110px}}
@media(max-width:380px){.dock-thumb{width:72px;height:72px}.dock{gap:10px}}

/* ---- phones (0.9.54): starting classes in three short columns ---- */
@media(max-width:560px){
  .sc-presets{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .sc-preset{flex-direction:column;justify-content:center;gap:2px;min-height:64px;padding:6px 2px;font-size:13px;text-align:center}
  .sc-preset canvas{width:34px;height:34px}
}
