/* Pixel Art & Sprite Studio — mobile-first sprite editor & animator */
:root{
  --ps-bg:#101320;--ps-surface:#171b2d;--ps-surface-2:#20263e;--ps-surface-3:#2b3354;
  --ps-text:#eef2ff;--ps-muted:#94a3c4;--ps-line:#2e3758;--ps-line-strong:#43507d;
  --ps-accent:#f43f5e;--ps-accent-2:#e11d48;--ps-accent-soft:#3d1628;--ps-on-accent:#ffffff;
  --ps-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --ps-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
.ps-app{display:flex;flex-direction:column;height:calc(100dvh - 108px);min-height:560px;max-height:960px;background:var(--ps-bg);color:var(--ps-text);font:13px/1.4 var(--ps-font);border:1px solid var(--ps-line);border-radius:14px;overflow:hidden;box-shadow:0 12px 32px rgba(0,0,0,.32)}
.ps-app *,.ps-app *::before,.ps-app *::after{box-sizing:border-box}
.ps-app button,.ps-app input,.ps-app select{font:inherit;color:inherit}
.ps-app :focus-visible{outline:2px solid var(--ps-accent);outline-offset:2px}

.ps-topbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px;padding:8px 10px;background:var(--ps-surface);border-bottom:1px solid var(--ps-line);flex:none}
.ps-bar-group{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.ps-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:36px;min-width:36px;padding:0 10px;border:1px solid var(--ps-line-strong);border-radius:9px;background:var(--ps-surface-2);cursor:pointer;font-weight:600;touch-action:manipulation}
.ps-btn:hover{background:var(--ps-surface-3)}
.ps-btn:disabled{opacity:.4;cursor:not-allowed}
.ps-btn-primary{background:var(--ps-accent);border-color:var(--ps-accent);color:var(--ps-on-accent)}
.ps-btn-primary:hover{background:var(--ps-accent-2)}
.ps-btn-sm{min-height:36px;min-width:36px;padding:0 9px;font-size:12px}
.ps-btn[aria-pressed=true]:not(.ps-btn-primary){background:var(--ps-accent-soft);border-color:var(--ps-accent);color:#fda4af}
.ps-select{min-height:36px;padding:0 9px;border:1px solid var(--ps-line-strong);border-radius:9px;background:var(--ps-surface-2);font-size:12px}
.ps-select-sm{min-height:36px;padding:0 8px}
.ps-inline{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--ps-muted)}
.ps-num{width:54px;min-height:36px;padding:0 6px;border:1px solid var(--ps-line-strong);border-radius:8px;background:var(--ps-surface-2);color:var(--ps-text);font:700 13px var(--ps-mono);text-align:center}

.ps-main{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.ps-stage-wrap{display:flex;flex-direction:column;flex:1 1 62%;min-height:280px;overflow:hidden}
.ps-tool-rail{display:flex;gap:4px;padding:6px 8px;background:var(--ps-surface);border-bottom:1px solid var(--ps-line);overflow-x:auto;flex:none}
.ps-tool{min-height:36px;min-width:44px;padding:0 10px;border:1px solid transparent;border-radius:8px;background:transparent;cursor:pointer;font-size:12px;font-weight:600;color:var(--ps-muted);white-space:nowrap;touch-action:manipulation}
.ps-tool.active{background:var(--ps-accent-soft);border-color:var(--ps-accent);color:#fda4af}
.ps-subbar{display:flex;align-items:center;gap:6px;padding:6px 8px;background:var(--ps-surface);border-bottom:1px solid var(--ps-line);overflow-x:auto;flex:none}

.ps-canvas-host{position:relative;flex:1;min-height:180px;display:flex;align-items:center;justify-content:center;overflow:hidden;background:radial-gradient(circle at 50% 45%,#1b2138,#0d101b);touch-action:none;user-select:none;-webkit-user-select:none}
.ps-canvas{image-rendering:pixelated;image-rendering:crisp-edges;border:1px solid var(--ps-line-strong);box-shadow:0 8px 28px rgba(0,0,0,.45);cursor:crosshair;touch-action:none;max-width:100%;max-height:100%}
.ps-hud-coords{position:absolute;left:10px;bottom:10px;padding:4px 9px;border-radius:8px;background:rgba(16,19,32,.85);border:1px solid var(--ps-line);font:11px var(--ps-mono);color:var(--ps-muted);pointer-events:none}
.ps-zoom-pill{position:absolute;right:10px;bottom:10px;display:inline-flex;align-items:center;gap:2px;padding:2px;border-radius:9px;background:rgba(23,27,45,.92);border:1px solid var(--ps-line)}
.ps-zoom-pill button{min-width:36px;min-height:36px;border:0;border-radius:7px;background:transparent;cursor:pointer;font-weight:700}
.ps-zoom-pill button:hover{background:var(--ps-surface-3)}
.ps-zoom-pill span{min-width:38px;text-align:center;font:12px var(--ps-mono)}

.ps-timeline{display:flex;flex-direction:column;gap:6px;padding:7px 8px;background:var(--ps-surface);border-top:1px solid var(--ps-line);flex:none}
.ps-tl-controls{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.ps-frames-strip{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px}
.ps-frame-thumb{display:flex;flex-direction:column;align-items:center;gap:3px;min-width:54px;padding:4px;border:2px solid var(--ps-line);border-radius:8px;background:var(--ps-surface-2);cursor:pointer;flex:none}
.ps-frame-thumb.active{border-color:var(--ps-accent);background:var(--ps-accent-soft)}
.ps-frame-thumb canvas{width:42px;height:42px;image-rendering:pixelated;border-radius:4px;background:#0f172a}
.ps-frame-thumb span{font:600 10px var(--ps-mono);color:var(--ps-muted)}

.ps-sidebar{flex:0 0 38%;min-height:190px;display:flex;flex-direction:column;background:var(--ps-surface);border-top:1px solid var(--ps-line);overflow:hidden}
.ps-preview-card{display:flex;align-items:center;gap:10px;padding:8px 10px;border-bottom:1px solid var(--ps-line);background:var(--ps-surface-2);flex:none}
.ps-preview-card canvas{width:68px;height:68px;image-rendering:pixelated;border:1px solid var(--ps-line-strong);border-radius:8px;background:#0d101b;flex:none}
.ps-preview-meta{display:flex;flex-direction:column;gap:6px;min-width:0;flex:1}
.ps-color-row{display:flex;align-items:center;gap:6px}
.ps-color-row input[type=color]{width:40px;height:36px;padding:2px;border:1px solid var(--ps-line-strong);border-radius:8px;background:var(--ps-surface);cursor:pointer}

.ps-tabs{display:grid;grid-template-columns:repeat(2,1fr);border-bottom:1px solid var(--ps-line);background:var(--ps-surface-2);flex:none}
.ps-tab{min-height:40px;border:0;border-bottom:2px solid transparent;background:transparent;cursor:pointer;font-weight:600;color:var(--ps-muted)}
.ps-tab.active{color:#fda4af;border-bottom-color:var(--ps-accent);background:var(--ps-surface)}
.ps-panel-body{flex:1;min-height:0;overflow-y:auto;padding:10px}
.ps-pane{display:flex;flex-direction:column;gap:10px}
.ps-pane[hidden]{display:none!important}
.ps-swatches{display:grid;grid-template-columns:repeat(auto-fill,minmax(36px,1fr));gap:5px}
.ps-swatch{width:100%;min-height:36px;border:2px solid rgba(255,255,255,.15);border-radius:7px;cursor:pointer;padding:0}
.ps-swatch.active{border-color:#ffffff;transform:scale(1.06);box-shadow:0 0 0 2px var(--ps-accent)}

.ps-layer-actions{display:flex;gap:6px;flex-wrap:wrap}
.ps-layers-list{display:flex;flex-direction:column;gap:6px}
.ps-layer-row{display:flex;align-items:center;gap:6px;padding:6px 8px;border:1px solid var(--ps-line);border-radius:9px;background:var(--ps-surface-2);cursor:pointer}
.ps-layer-row.active{border-color:var(--ps-accent);background:var(--ps-accent-soft)}
.ps-layer-name{flex:1;font-weight:600;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ps-layer-vis{min-width:36px;min-height:36px;border:1px solid var(--ps-line-strong);border-radius:7px;background:var(--ps-surface);cursor:pointer;font-size:12px}

.ps-dialog{width:min(460px,92vw);padding:0;border:1px solid var(--ps-line);border-radius:14px;background:var(--ps-surface);color:var(--ps-text);box-shadow:0 20px 60px rgba(0,0,0,.5)}
.ps-dialog::backdrop{background:rgba(6,8,16,.68);backdrop-filter:blur(3px)}
.ps-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid var(--ps-line)}
.ps-dialog-head h2{margin:0;font-size:15px}
.ps-dialog-body{padding:14px;display:flex;flex-direction:column;gap:12px}
.ps-btn-grid{display:grid;grid-template-columns:1fr;gap:8px}
.ps-hint{margin:0;font-size:12px;color:var(--ps-muted)}

@media (min-width:920px){
  .ps-main{flex-direction:row}
  .ps-stage-wrap{flex:1 1 auto;min-height:0}
  .ps-sidebar{flex:0 0 300px;border-top:0;border-left:1px solid var(--ps-line)}
}
@media (max-width:600px){
  .ps-app{height:calc(100dvh - 80px);border-radius:10px}
}
