/* CanvasForge compact responsive UI. Panels are retractable, resizable and edge-revealable. */
:root{color-scheme:dark;--bg:#0a0f1c;--panel:#141c2d;--panel2:#1b253a;--line:#33415f;--text:#edf2ff;--muted:#a8b2ca;--accent:#62a5ff;--bar:42px;--tabs:34px;--foot:23px;--panel-w:250px;--pad:4px;--radius:8px}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}body{background:var(--bg);color:var(--text);font:12px/1.25 system-ui,-apple-system,"Segoe UI",sans-serif;touch-action:none;user-select:none}button,input,select,textarea{font:inherit;color:inherit}button,select,input:not([type=range]):not([type=color]){min-height:28px;background:#202b43;border:1px solid var(--line);border-radius:6px;padding:2px 6px}button{cursor:pointer}button:hover,button:focus-visible{border-color:var(--accent)}button.active{background:var(--accent);color:#061124}input[type=range]{width:100%;height:18px;accent-color:var(--accent)}input[type=color]{width:38px;height:28px;border:0;background:none;padding:0}output{min-width:42px;text-align:right;color:var(--muted)}#app{height:100dvh;display:grid;grid-template-rows:var(--bar) var(--tabs) 1fr var(--foot)}#topbar,#tabs,footer{display:flex;align-items:center;gap:3px;background:var(--panel);padding:3px 5px;z-index:40;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}#topbar::-webkit-scrollbar,#tabs::-webkit-scrollbar{display:none}#topbar{border-bottom:1px solid var(--line)}#topbar button{white-space:nowrap;min-height:30px;padding-inline:7px}.brand{font-size:13px;margin-right:5px;font-weight:700;color:inherit;text-decoration:none;cursor:pointer;display:inline-block}.brand:hover{color:var(--accent)}.grow{flex:1;min-width:4px}#quickBar{display:flex;gap:3px}#tabs{border-bottom:1px solid var(--line)}#tabs button{min-height:25px;padding:1px 7px}.tab.active{background:var(--accent);color:#07101f}footer{justify-content:space-between;color:var(--muted);border-top:1px solid var(--line);font-size:11px}#workspace{position:relative;min-height:0;overflow:hidden;background:#20283a}.checker{position:absolute;inset:0;background-image:linear-gradient(45deg,#293247 25%,transparent 25%),linear-gradient(-45deg,#293247 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#293247 75%),linear-gradient(-45deg,transparent 75%,#293247 75%);background-size:18px 18px;background-position:0 0,0 9px,9px -9px,-9px 0}#view{position:absolute;left:50%;top:50%;transform-origin:0 0;box-shadow:0 12px 35px #0008,0 0 0 1px #fff4;touch-action:none;cursor:crosshair}.panel{position:absolute;top:4px;bottom:4px;width:var(--panel-w);min-width:170px;max-width:520px;display:flex;flex-direction:column;background:#141c2df8;border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 10px 30px #0008;z-index:30;transition:transform .16s ease}.panel.left{left:4px}.panel.right{right:4px}.panel.left.closed{transform:translateX(calc(-100% - 8px))}.panel.right.closed{transform:translateX(calc(100% + 8px))}.panel-head{height:30px;display:flex;align-items:center;justify-content:space-between;padding:2px 5px;border-bottom:1px solid var(--line);cursor:default}.panel-actions{display:flex;gap:2px}.panel-actions button{width:27px;padding:0}.panel-body{padding:4px;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:var(--line) transparent}.panel section{margin:0 0 7px}.panel h3{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin:4px 1px}.panel label{display:grid;grid-template-columns:56px 1fr auto;align-items:center;gap:3px;margin:2px 0;min-height:24px}.panel label.check{grid-template-columns:1fr auto}.tool-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:2px}.tool-grid button{min-width:0;min-height:30px;padding:1px 2px;font-size:11px}.colour-row{display:grid;grid-template-columns:38px 1fr auto;gap:3px}#swatches,#recentSwatches{display:grid;grid-template-columns:repeat(12,1fr);gap:2px;margin-top:3px}.swatch{aspect-ratio:1;min-height:0;padding:0;border-radius:3px}.compact-actions{display:flex;gap:2px;margin:2px 0}.compact-actions button,.compact-actions .file-btn{flex:1;padding:1px 3px;min-width:0}
.file-btn{display:flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:6px;background:var(--panel2);cursor:pointer;text-align:center}
.file-btn:hover{border-color:var(--accent)}
.preset-list{display:flex;flex-direction:column;gap:2px;max-height:168px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent;margin-bottom:3px}
.preset-row{display:grid;grid-template-columns:auto 1fr auto auto;align-items:center;gap:5px;background:var(--panel2);border:1px solid var(--line);border-radius:5px;padding:3px 5px;cursor:pointer}
.preset-row.active{border-color:var(--accent)}
.preset-swatch{border-radius:50%;flex:none}
.preset-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px}
.preset-star,.preset-del{min-height:0;padding:0 3px;background:none;border:0;font-size:12px;line-height:1}
.preset-del{color:var(--muted)}
.preset-del:hover{color:#ff8080}
.curve-preview{display:block;width:100%;height:46px;background:var(--panel2);border:1px solid var(--line);border-radius:5px;margin:3px 0}
#brushCursor{position:absolute;z-index:27;pointer-events:none;transform:translate(-50%,-50%);border:1.5px solid var(--accent);box-shadow:0 0 0 1px #000a,inset 0 0 0 1px #000a;background:transparent}
#brushCursor.eraser{border-color:#fff}
#brushCursor[hidden]{display:none}
#brushRawDot{position:absolute;z-index:27;pointer-events:none;transform:translate(-50%,-50%);width:5px;height:5px;border-radius:50%;background:#ffb020;box-shadow:0 0 0 1px #000a}
#brushRawDot[hidden]{display:none}
.save-status{font-size:11px;color:var(--muted);white-space:nowrap;padding:0 2px;display:flex;align-items:center;gap:4px}
.save-status::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--muted)}
.save-status[data-state="saved"]::before{background:#3ecf7e}
.save-status[data-state="saving"]::before{background:#e0b23c;animation:pulse 1s ease-in-out infinite}
.save-status[data-state="unsaved"]::before{background:#e0663c}
@keyframes pulse{50%{opacity:.35}}
/* Fixed and out of #app's grid flow on purpose: #app's grid-template-rows
   is a fixed 4-track list (bar/tabs/1fr/foot) matching its 4 normal
   children, so this banner being a 5th DOM child there would consume the
   1fr content track and squash the real workspace into the footer's track.
   Overlaying it instead keeps the grid untouched. */
.recovery-banner{position:fixed;left:0;right:0;top:calc(var(--bar) + var(--tabs));z-index:35;display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:#1b253af5;border-bottom:1px solid var(--accent);box-shadow:0 6px 18px #0008;padding:6px 10px;font-size:12px}
.recovery-banner[hidden]{display:none}
.recovery-banner button{min-height:26px;padding:2px 10px}.layer{display:grid;grid-template-columns:22px 34px 18px 1fr 20px 22px 22px;gap:4px;align-items:center;background:var(--panel2);border:2px solid var(--line);border-radius:5px;padding:2px;margin:3px 0 3px 0;cursor:pointer;position:relative}
.layer.clipped{margin-left:12px;border-style:dashed}
.layer-clip{background:none;border:0;color:var(--muted);font-size:13px}
.layer-clip.active{color:var(--accent)}
.layer-clip:hover{color:var(--accent)}
.layer.active{border-color:var(--accent)}
.layer.multi-selected{background:#26365a}
.layer.dragging{opacity:.4}
.layer.drag-over-top{box-shadow:inset 0 2px 0 var(--accent)}
.layer.drag-over-bottom{box-shadow:inset 0 -2px 0 var(--accent)}
.layer button{min-height:24px;padding:0}
.layer-thumb{width:34px;height:24px;border-radius:3px;overflow:hidden;background:repeating-conic-gradient(#0000 0 25%,#0002 0 50%) 0 0/8px 8px;flex:none;display:flex;align-items:center;justify-content:center;transition:opacity .15s}
.layer-thumb img{width:100%;height:100%;object-fit:contain}
.mask-badge{width:18px;height:24px;padding:0;border-radius:3px;background:#000;overflow:hidden;display:flex;align-items:center;justify-content:center;flex:none;border:1px solid var(--line)}
.mask-badge img{width:100%;height:100%;object-fit:contain}
.mask-badge.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.mask-badge--add{background:var(--panel2);color:var(--muted);opacity:.55}
.mask-badge--add:hover{opacity:1;color:inherit}
.mask-badge--add svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.6;display:block;margin:0 auto;pointer-events:none}
.layer:has(.mask-badge.active) .layer-thumb{opacity:.4}
.layer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.layer-vis,.layer-lock,.layer-export{background:none;border:0}
.layer-vis:hover,.layer-lock:hover,.layer-export:hover{color:var(--accent)}
.layer-bulk-bar{display:flex;align-items:center;gap:4px;flex-wrap:wrap;background:var(--panel2);border:1px solid var(--accent);border-radius:6px;padding:4px 6px;margin:4px 0;font-size:11px}
.layer-bulk-bar[hidden]{display:none}
.layer-bulk-bar span{margin-right:auto}
.layer-bulk-bar button{min-height:22px;padding:0 5px}
.export-layer-list{display:flex;flex-direction:column;gap:2px;max-height:160px;overflow-y:auto;border:1px solid var(--line);border-radius:6px;padding:5px;margin:4px 0;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
.export-layer-row{display:flex;align-items:center;gap:6px;font-size:12px}.layer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.resize-grip{position:absolute;top:30px;bottom:0;width:7px;cursor:ew-resize}.left .resize-grip{right:-3px}.right .resize-grip{left:-3px}.edge-reveal{position:absolute;top:0;bottom:0;width:8px;z-index:29;opacity:.25;background:var(--accent);transition:width .15s,opacity .15s;display:grid;place-items:center;overflow:hidden}.edge-reveal:hover{width:28px;opacity:.9}.edge-reveal.left{left:0}.edge-reveal.right{right:0}.edge-reveal span{writing-mode:vertical-rl;font-size:9px;font-weight:700;letter-spacing:.15em;color:#07101f}#selectionBox{position:absolute;border:1px dashed #fff;outline:1px dashed #000;pointer-events:none;z-index:25}.handle{position:absolute;width:7px;height:7px;background:#fff;border:1px solid #000}.handle.nw{left:-4px;top:-4px}.handle.ne{right:-4px;top:-4px}.handle.sw{left:-4px;bottom:-4px}.handle.se{right:-4px;bottom:-4px}
/* A flex column: the drag/commit bar sits in normal document flow directly
   above the content (never absolutely positioned above the box), so
   #workspace's own overflow:hidden can never clip it off even when the
   paste is dragged right up against the top edge. */
#floatingPaste{position:absolute;z-index:26;display:flex;flex-direction:column;align-items:flex-start;max-width:calc(100vw - 20px)}#floatingPaste[hidden]{display:none}
.floating-bar{display:flex;align-items:center;gap:4px;background:#0c1426f2;border:1px solid var(--line);border-radius:6px 6px 0 0;padding:3px 4px;white-space:nowrap;cursor:move;font-size:11px;box-shadow:0 4px 12px #0006;margin-bottom:-1px;position:relative;z-index:1}
.floating-bar button{min-height:22px;padding:1px 7px}
.floating-size{display:flex;align-items:center;gap:3px;cursor:default}.floating-size input{width:52px;min-height:22px}
.floating-image{position:relative;outline:2px dashed var(--accent);outline-offset:-2px;line-height:0}.floating-image img,.floating-image canvas{display:block;max-width:min(70vw,600px);max-height:min(70vh,600px);width:auto;height:auto;pointer-events:none}
.floating-resize{position:absolute;right:-7px;bottom:-7px;width:14px;height:14px;border-radius:50%;background:var(--accent);border:2px solid #0c1426;cursor:nwse-resize;pointer-events:auto}
#floatingTextarea{display:block;width:280px;min-height:64px;background:#0c1426b3;border:2px dashed var(--accent);border-radius:0 4px 4px 4px;padding:6px;resize:both;outline:none;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;line-height:1.2}dialog{width:min(440px,calc(100vw - 18px));max-height:88dvh;overflow:auto;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:10px;padding:12px;box-shadow:0 20px 70px #000b}dialog::backdrop{background:#020617aa}dialog h2{margin:0 0 10px}dialog label{display:grid;grid-template-columns:110px 1fr;gap:7px;align-items:center;margin:6px 0}dialog menu{display:flex;justify-content:flex-end;gap:5px;padding:8px 0 0;margin:0}.hint{color:var(--muted)}
.hint-inline{text-transform:none;letter-spacing:0;font-weight:400;opacity:.7}#helpContent{display:grid;grid-template-columns:auto 1fr;gap:5px 12px}kbd{background:#202b43;border:1px solid var(--line);border-bottom-width:2px;padding:2px 5px;border-radius:4px}#toast{position:fixed;left:50%;bottom:30px;translate:-50%;z-index:100;background:#0c1426;border:1px solid var(--line);border-radius:7px;padding:7px 10px;box-shadow:0 8px 25px #0009}
.tool-grid button svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;display:block;margin:0 auto;pointer-events:none}
#topbar button svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;display:block;margin:0 auto;pointer-events:none}
.layer-lock svg,#deletePreset svg,.layer-bulk-bar button svg,[data-command="deleteLayer"] svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;display:block;margin:0 auto;pointer-events:none}
#helpContent h3.help-heading{grid-column:1/-1;margin:8px 0 1px}
#helpContent h3.help-heading:first-child{margin-top:0}
.help-icon-key{display:flex;align-items:center;justify-content:center;padding:2px 6px}
.help-icon-key svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.recent-label{font-size:9px;color:var(--muted);margin:5px 0 1px;text-transform:uppercase;letter-spacing:.06em}
.swatch--empty{background:repeating-linear-gradient(45deg,#1b253a,#1b253a 4px,#141c2d 4px,#141c2d 8px);border-style:dashed;cursor:default}
.swatch--empty:hover{border-color:var(--line)}
.colour-swatch-btn{width:38px;height:28px;padding:0;border-radius:6px;box-shadow:inset 0 0 0 1px #fff2}
.palette-head{display:flex;align-items:center;justify-content:space-between;margin-top:5px}
.palette-head .recent-label{margin:0}
.palette-actions{display:flex;gap:2px}
.palette-actions button,.palette-actions .file-btn{padding:1px 5px;font-size:10px;min-height:22px}
#customPalette{display:grid;grid-template-columns:repeat(12,1fr);gap:2px;margin-top:3px;min-height:20px}
.palette-empty-hint:empty::before{content:attr(data-hint);grid-column:1/-1;color:var(--muted);font-size:10px;font-style:italic;padding:2px 1px}
.wheel-area{position:relative;width:220px;height:220px;margin:4px auto}
#wheelCanvas{display:block;width:220px;height:220px;border-radius:50%;touch-action:none;cursor:crosshair}
.wheel-dot{position:absolute;width:14px;height:14px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #000a,0 1px 3px #0008;transform:translate(-50%,-50%);pointer-events:none;background:transparent}
.wheel-dot:focus-visible{box-shadow:0 0 0 1px #000a,0 1px 3px #0008,0 0 0 3px var(--accent)}
.wheel-controls{display:flex;align-items:center;gap:6px;margin-top:10px}
.wheel-preview{width:32px;height:28px;border-radius:6px;box-shadow:inset 0 0 0 1px #fff2;flex:none}
.wheel-controls input{flex:1;min-width:0}
.navigator-wrap{position:relative;width:200px;height:140px;margin:4px auto 6px;display:flex;align-items:center;justify-content:center;background:#0c1426;border:1px solid var(--line);border-radius:6px;overflow:hidden;cursor:crosshair}
#navigatorCanvas{display:block}
#navigatorViewport{position:absolute;left:0;top:0;border:1.5px solid var(--accent);background:#62a5ff26;box-shadow:0 0 0 1px #000a;pointer-events:none}
#navigatorViewport[hidden]{display:none}
.history-list{display:flex;flex-direction:column;gap:2px;max-height:260px;overflow-y:auto}
.history-entry{display:grid;grid-template-columns:1fr 22px 22px 22px;gap:2px;align-items:center;background:var(--panel2);border:1px solid var(--line);border-radius:5px;padding:2px 3px;margin:2px 0}
.history-entry.starred{border-color:#facc15}
.history-entry button{min-height:22px;padding:0;font-size:11px}
.history-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}
.about-box{background:#fff;color:#16181d;border-radius:8px;padding:10px 12px;margin:4px 0 10px}
.about-box h3{margin:0 0 6px;font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:#5b6270}
.about-box p{margin:0 0 8px;color:#16181d;font-size:12px;line-height:1.4}
.about-link{color:#1a56a6;font-weight:600;text-decoration:none;font-size:12px}
.about-link:hover{text-decoration:underline}
@media(max-width:760px){:root{--bar:39px;--panel-w:min(235px,calc(100vw - 12px))}.brand{display:none}#topbar{padding:2px}#topbar button{min-height:29px;padding-inline:5px}.panel{top:2px;bottom:2px}.panel.left{left:2px}.panel.right{right:2px}#docInfo{display:none}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
