/* ===== Pixel Canvas Editor Page ===== */

.editor-page [hidden]{
    display:none !important;
}

body.editor-page{
    margin:0;
    height:100dvh;
    max-height:100dvh;
    min-height:100dvh;
    display:flex;
    flex-direction:column;
    background:#080a14;
    color:#fff;
    overflow:hidden;
    touch-action:none;
}

body.editor-page::before{
    display:none;
}

.editor-topbar{
    display:flex;
    align-items:center;
    gap:12px;
    flex-shrink:0;
    padding:10px 16px;
    padding-top:max(10px, env(safe-area-inset-top));
    border-bottom:1px solid rgba(255,255,255,.08);
    background:rgba(0,0,0,.5);
    z-index:10;
}

.editor-back{
    color:var(--accent);
    text-decoration:none;
    font-size:14px;
    white-space:nowrap;
}

.editor-back:hover{ opacity:.85; }

.editor-title{
    font-weight:600;
    font-size:15px;
}

.editor-status{
    flex:1;
    text-align:right;
    color:var(--sub);
    font-size:12px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.editor-auth{
    flex:1;
    min-height:0;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
    overflow:auto;
}

.editor-auth-card{
    width:min(400px, 100%);
    padding:32px 28px;
    border-radius:16px;
    background:rgba(255,255,255,.05);
    border:1px solid rgba(255,255,255,.1);
    text-align:center;
}

.editor-auth-card h2{
    margin:0 0 8px;
    font-size:22px;
}

.editor-auth-card p{
    margin:0 0 20px;
    color:var(--sub);
    font-size:14px;
}

.editor-auth-card .canvas-code-input{
    width:100%;
    max-width:220px;
    margin-bottom:16px;
}

.editor-auth-actions{
    display:flex;
    gap:10px;
    justify-content:center;
    flex-wrap:wrap;
}

.editor-workspace{
    flex:1;
    min-height:0;
    width:100%;
    display:grid;
    grid-template-columns:auto 1fr auto;
    grid-template-rows:minmax(0, 1fr);
    overflow:hidden;
}

.editor-sidebar{
    display:flex;
    flex-direction:column;
    gap:12px;
    padding:12px 8px;
    border-right:1px solid rgba(255,255,255,.08);
    background:rgba(0,0,0,.35);
    overflow-y:auto;
}

.editor-tool-group,
.editor-zoom-group{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:6px;
}

.editor-tool-btn{
    width:44px;
    height:44px;
    border:1px solid rgba(255,255,255,.12);
    border-radius:10px;
    background:rgba(255,255,255,.06);
    color:#fff;
    font-size:18px;
    cursor:pointer;
    transition:.2s;
    padding:0;
    line-height:1;
}

.editor-tool-btn:hover{
    background:rgba(255,255,255,.12);
    border-color:rgba(247,217,109,.35);
}

.editor-tool-btn.active{
    background:rgba(247,217,109,.2);
    border-color:var(--accent);
    color:var(--accent);
}

.editor-sidebar input[type="color"]{
    width:44px;
    height:44px;
    padding:2px;
    border:1px solid rgba(255,255,255,.15);
    border-radius:10px;
    background:transparent;
    cursor:pointer;
}

.editor-sidebar .canvas-brush-select{
    width:44px;
    padding:6px 2px;
    font-size:11px;
    text-align:center;
}

.editor-zoom-label{
    font-size:11px;
    color:var(--sub);
    text-align:center;
    min-width:44px;
}

.editor-canvas-area{
    min-width:0;
    min-height:0;
    height:100%;
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.editor-viewport{
    flex:1;
    min-height:0;
    overflow:hidden;
    position:relative;
    background:
        linear-gradient(45deg, #1a1d2a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1d2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1d2a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1d2a 75%);
    background-size:16px 16px;
    background-position:0 0, 0 8px, 8px -8px, -8px 0;
    background-color:#12151f;
    cursor:crosshair;
    touch-action:none;
}

.editor-viewport.tool-hand{ cursor:grab; }
.editor-viewport.tool-hand.is-panning{ cursor:grabbing; }
.editor-viewport.tool-picker{ cursor:cell; }

.editor-transform{
    position:absolute;
    top:0;
    left:0;
    transform-origin:0 0;
    will-change:transform;
}

.editor-transform canvas{
    position:absolute;
    top:0;
    left:0;
    image-rendering:pixelated;
    image-rendering:crisp-edges;
    -ms-interpolation-mode:nearest-neighbor;
    box-shadow:0 0 0 1px rgba(255,255,255,.15), 0 8px 32px rgba(0,0,0,.5);
}

#canvasGrid{
    pointer-events:none;
    z-index:2;
}

.editor-hint{
    flex-shrink:0;
    margin:0;
    padding:6px 12px;
    text-align:center;
    font-size:11px;
    color:rgba(255,255,255,.3);
    border-top:1px solid rgba(255,255,255,.06);
}

.editor-admin-hint{
    margin:0;
    color:var(--accent);
    font-size:12px;
    line-height:1.4;
}

.editor-session-actions{
    display:flex;
    flex-direction:column;
    gap:8px;
    width:100%;
}

.editor-session-actions .canvas-tool-btn{
    width:100%;
}

.editor-actions{
    display:flex;
    flex-direction:column;
    gap:8px;
    padding:12px;
    width:min(160px, 22vw);
    border-left:1px solid rgba(255,255,255,.08);
    background:rgba(0,0,0,.35);
    overflow-y:auto;
}

.editor-session-user{
    margin:0;
    color:var(--accent);
    font-size:13px;
    font-weight:600;
}

.editor-session-cost{
    margin:0 0 4px;
    color:var(--sub);
    font-size:12px;
    line-height:1.4;
}

.editor-actions .canvas-tool-btn{
    width:100%;
}

.editor-admin-bar{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-top:8px;
    padding-top:8px;
    border-top:1px solid rgba(255,255,255,.08);
}

.canvas-edit-link{
    display:inline-block;
    margin-top:8px;
    padding:12px 24px;
    border-radius:10px;
    background:rgba(247,217,109,.12);
    border:1px solid rgba(247,217,109,.3);
    color:var(--accent);
    text-decoration:none;
    font-size:14px;
    font-weight:600;
    transition:.3s;
}

.canvas-edit-link:hover{
    background:rgba(247,217,109,.22);
}

@media(max-width:768px){
    .editor-workspace{
        grid-template-columns:1fr;
        grid-template-rows:auto minmax(0, 1fr) auto;
    }

    .editor-sidebar{
        flex-direction:row;
        flex-wrap:wrap;
        justify-content:center;
        border-right:none;
        border-bottom:1px solid rgba(255,255,255,.08);
        padding:8px;
    }

    .editor-tool-group,
    .editor-zoom-group{
        flex-direction:row;
    }

    .editor-actions{
        width:100%;
        flex-direction:row;
        flex-wrap:wrap;
        align-items:center;
        border-left:none;
        border-top:1px solid rgba(255,255,255,.08);
        padding:8px 10px;
    }

    .editor-session-user,
    .editor-session-cost{
        flex:1;
        min-width:120px;
    }

    .editor-actions .canvas-tool-btn{
        width:auto;
        flex:1;
        min-width:70px;
        padding:10px 8px;
        font-size:12px;
    }

    .editor-hint{ display:none; }
}
