.cp{display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:22px;align-items:start}
.cp-stage{border:1px solid var(--line);background:#0b0b0a;padding:14px;min-width:0}
.cp-stage canvas{display:block;width:100%;height:auto;touch-action:none;cursor:crosshair;background:#fff}
.cp-bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-bottom:14px}
.cp-side{display:grid;gap:12px;min-width:0}
.cp-side details{border:1px solid var(--line);background:#10100e;padding:14px}
.cp-side summary{font:9px var(--mono);letter-spacing:.14em;color:var(--accent);cursor:pointer}
.cp-side details>*+*{margin-top:12px}
.cp-two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.cp-layer{display:grid;grid-template-columns:1fr auto;gap:6px}
.cp-layer.on button:first-child{border-color:var(--accent);color:var(--accent)}
.cp-swatches{display:flex;gap:6px;flex-wrap:wrap}
.cp-swatches button{width:24px;height:24px;padding:0;border:1px solid #494035;background:var(--sw,#000);cursor:pointer}
.cp-check{display:flex;gap:9px;align-items:center;font-size:12px;color:#c6bfb4}
.cp-tip{font-size:11px;color:var(--muted);line-height:1.7}
@media(max-width:1000px){.cp{grid-template-columns:1fr}}
/* "ADVANCED_CANVAS." is longer than the old heading, and the page heading breaks
   anywhere; keep the outlined word whole so phones break between the two words. */
.tools-heading h1 .outline-text{white-space:nowrap}
/* The six tool buttons need 313px; narrower screens (a 320px phone, or a desktop
   at 400% zoom) scrolled the whole page sideways while the last button sat half
   off-screen. Two rows of three keep every tool on screen and in reach. */
@media(max-width:400px){
  .segmented-controls{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;width:100%}
  .segmented-controls button+button{border-left:1px solid #494035}
}
.cp-canvas-wrap{min-width:0}
.cp-expand{margin-left:auto;white-space:nowrap;min-height:44px;padding:10px 14px;font-size:9px}
body.canvas-expanded{overflow:hidden}
.cp.is-expanded{position:fixed;inset:0;z-index:240;display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:0;align-items:stretch;background:#080808;padding:0;overflow:hidden;overscroll-behavior:contain}
.cp.is-expanded .cp-stage{display:flex;flex-direction:column;height:100%;min-height:0;padding:12px;border:0}
.cp.is-expanded .cp-bar{flex:0 0 auto;margin-bottom:10px}
.cp.is-expanded .cp-canvas-wrap{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center}
.cp.is-expanded canvas{width:auto;height:auto;max-width:100%;max-height:100%;margin:auto}
.cp.is-expanded #cp-status{flex:0 0 auto;margin-top:10px}
.cp.is-expanded .cp-side{height:100%;overflow-y:auto;align-content:start;padding:12px;border-top:0;border-left:1px solid var(--line);background:#0b0b0a}
@media(max-width:1000px){
  .cp.is-expanded{display:block;overflow-y:auto;align-items:start}
  .cp.is-expanded .cp-stage{display:block;height:auto;min-height:0}
  .cp.is-expanded .cp-canvas-wrap{display:block;width:100%}
  .cp.is-expanded canvas{width:100%;height:auto;max-height:none;margin:0}
  .cp.is-expanded .cp-side{height:auto;overflow:visible;border-left:0;border-top:1px solid var(--line);padding:14px}
}
/* Stacked layouts (phone and tablet): every swatch and slider gets a 44x44 hit region. The squares
   stay 24px and the slider track keeps its native thickness; only the boxes
   around them grow, so the drawing surface and desktop look are untouched. */
@media(max-width:1000px){
  .cp-swatches{display:grid;grid-template-columns:repeat(4,44px);gap:6px;justify-content:start}
  .cp-swatches button{position:relative;width:44px;height:44px;padding:0;border:0;background:transparent}
  .cp-swatches button::after{content:"";position:absolute;inset:0;margin:auto;width:24px;height:24px;border:1px solid #494035;background:var(--sw,#000)}
  .cp .tool-field input[type="range"]{min-height:44px}
}
