/* Background Creator Stage 1.3: Puzzle Arcade style, one main table with right-side slide-out drawers. */
.sbg-page{max-width:1650px;margin-inline:auto}
.sbg-page *{box-sizing:border-box}
.sbg-page button,.sbg-page select,.sbg-page input,.sbg-page textarea{font:inherit}
.sbg-page button,.sbg-link{cursor:pointer;border:1px solid #b9dac6;background:#fcfff9;color:#15543f;border-radius:10px;padding:8px 11px;min-height:36px}
.sbg-page button:hover,.sbg-link:hover{background:#e8f7ea}
.sbg-page button:focus-visible,.sbg-page input:focus-visible,.sbg-page select:focus-visible,.sbg-page textarea:focus-visible,.sbg-page .sbg-layer:focus-within{outline:3px solid #36a7a3;outline-offset:2px}
.sbg-page button[disabled]{opacity:.45;cursor:not-allowed}
.sbg-page button[aria-pressed=true],.sbg-page .sbg-item.selected{background:#d5eee1;border-color:#18856c;color:#0d5146}
.sbg-toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;border:1px solid #c1dec8;background:#f5fff5;border-radius:16px;padding:9px;margin:12px 0}
.sbg-toolbar label{display:flex;align-items:center;gap:8px;font-weight:700;max-width:300px}.sbg-toolbar input{width:min(220px,40vw);padding:9px;border:1px solid #b6cfbd;border-radius:9px;background:#fff}
.sbg-toolbar #sbg-publish{background:#195e4b;color:#fff}.sbg-toolbar #sbg-status{margin-left:auto;font-size:.86rem;font-weight:500}.sbg-error{color:#a33325!important}
/* No permanent left and right columns. The board uses nearly all available width. */
/* The artboard keeps the same grid width whether drawers are open or closed. */
.sbg-layout{display:grid;grid-template-columns:minmax(0,1fr) 62px;gap:8px;align-items:start;position:relative}

.sbg-workspace{min-width:0}
.sbg-table-heading{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:8px 10px;border:1px solid #bfd9c3;background:#f0f8f0;border-radius:13px;margin-bottom:8px}
.sbg-table-heading strong{white-space:nowrap}.sbg-table-heading .sbg-muted{flex:1;min-width:200px}
.sbg-muted{font-size:.78rem;color:#537466;line-height:1.5}
.sbg-viewport{width:100%;height:clamp(330px,69vh,760px);overflow:auto;background:#dcebe0;border:4px solid #3e7b64;border-radius:18px;position:relative;scrollbar-gutter:stable}
#sbg-canvas{display:block;width:960px;height:640px;max-width:none;cursor:crosshair;touch-action:none;box-shadow:0 3px 15px #183d2b33;margin:10px auto}
.sbg-bottom{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;padding:7px 9px;font-size:.8rem;color:#567266}
.sbg-bottom label,.sbg-layer-foot label{display:inline-flex;gap:5px;align-items:center}
/* Layer tools live underneath the board, like Sticker Scenes, not in a distant sidebar. */
.sbg-layers-tray{border:1px solid #bfdbc6;background:#f6fcf4;border-radius:14px;padding:10px;margin:5px 0 14px}
.sbg-layers-heading{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:9px}
.sbg-layers-heading strong{font-size:.9rem}.sbg-layers-heading .sbg-muted{flex:1}
.sbg-layers-heading button{font-size:.77rem;min-height:30px;padding:4px 8px}
.sbg-layers{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}
.sbg-layer{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:4px;align-items:stretch;background:#fff;border:1px solid #d1e2d4;padding:4px;border-radius:11px;min-width:0}
.sbg-layer.active{background:#def7eb;border-color:#18856c;box-shadow:inset 3px 0 #18856c}
.sbg-layer.is-hidden{background:#f0f0ee;border-style:dashed;opacity:.68}
.sbg-layer .sbg-layer-select{display:flex;align-items:center;text-align:left;gap:6px;flex:1;border:none;background:transparent;color:inherit;padding:4px 3px;min-width:0;min-height:34px}
.sbg-layer .sbg-layer-select:hover{background:#e6f5ea}
.sbg-layer .sbg-layer-select:before{content:'';width:11px;height:11px;min-width:11px;border:1.5px solid #8ba99a;border-radius:50%;background:#fff}
.sbg-layer.active .sbg-layer-select:before{background:#18856c;box-shadow:inset 0 0 0 2px #fff}
.sbg-layer .sbg-layer-label{font-size:.78rem;overflow-wrap:anywhere;line-height:1.2}
.sbg-layer .sbg-layer-count{margin-left:auto;font-size:.7rem;color:#648273;font-variant-numeric:tabular-nums}
.sbg-layer .sbg-layer-toggle{min-width:30px;min-height:30px;padding:1px 5px;font-size:.86rem;line-height:1;background:#fff}
.sbg-layer.is-hidden .sbg-layer-eye{color:#894542;background:#f9e9e7;border-color:#d9abaa}
.sbg-layer-foot{display:flex;flex-wrap:wrap;gap:10px;align-items:center;font-size:.78rem;margin-top:9px;color:#506d62}
.sbg-layer-foot #sbg-selected-readout{flex:1;min-width:140px;font-weight:600}
/* Puzzle-style independent, simultaneously open slide-out drawers. */
.sbg-dock{position:relative;z-index:12;min-width:0;width:62px}

.sbg-dock-tabs{display:flex;flex-direction:column;gap:5px;align-items:stretch}
.sbg-dock-tabs button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:53px;padding:5px 2px;font-size:1.1rem;border-radius:10px;text-align:center}
.sbg-dock-tabs button span{font-size:.65rem;line-height:1.1}
.sbg-dock-tabs button[aria-expanded=true]{border:2px solid #1b866b;background:#d6f2e1}
/* When there is room, drawers sit OUTSIDE the board, right of the tab rail. */
.sbg-dock-panels{position:absolute;left:calc(100% + 8px);right:auto;top:0;display:flex;flex-direction:row;align-items:flex-start;gap:8px;min-width:0;max-width:min(650px,var(--sbg-room-right,320px));width:max-content;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;pointer-events:none;padding:0 0 8px}
.sbg-dock-panels:not(.has-open){display:none}
.sbg-dock-panel{position:relative;flex:0 0 min(300px,calc(100vw - 130px));width:min(300px,calc(100vw - 130px));max-height:min(78vh,780px);overflow:hidden;border:1px solid #add0ba;border-radius:16px;background:#fbfff9;box-shadow:0 8px 28px #132f2670;display:flex;flex-direction:column;pointer-events:auto}
.sbg-dock-panel[hidden]{display:none!important}
.sbg-drawer-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;background:#e6f4e9;padding:9px 11px;border-bottom:1px solid #c0d8c4}
.sbg-drawer-heading button{padding:1px 8px;min-height:29px}
.sbg-drawer-section{padding:12px;overflow-y:auto;max-height:min(72vh,715px);scrollbar-gutter:stable}
.sbg-drawer-section label,.sbg-page dialog label{display:flex;flex-direction:column;gap:5px;margin:10px 0;font-weight:600;font-size:.85rem}
.sbg-drawer-section input:not([type=radio]):not([type=checkbox]),.sbg-drawer-section select,.sbg-page dialog input:not([type=checkbox]),.sbg-page dialog select,.sbg-page dialog textarea{background:#fff;border:1px solid #b7d3c1;border-radius:8px;max-width:100%;padding:9px}
.sbg-items{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
.sbg-item{min-width:0;display:flex;flex-direction:column;align-items:center;gap:5px;background:#fff!important;padding:6px!important;position:relative}
.sbg-item img{width:100%;height:88px;object-fit:contain;image-rendering:auto}
.sbg-item span{font-size:.75rem;line-height:1.25;overflow-wrap:anywhere;max-height:2.6em;overflow:hidden}
.sbg-tools{display:grid;grid-template-columns:1fr 1fr;gap:7px}.sbg-tools button{font-size:.79rem}.sbg-tools button:last-child{grid-column:1/-1}
.sbg-actions{display:grid;grid-template-columns:1fr 1fr;gap:7px}.sbg-actions button{font-size:.8rem}
.sbg-page fieldset{border:1px solid #c4dbc8;border-radius:11px;margin:0 0 12px;padding:10px}.sbg-page legend{color:#1b5a49;font-weight:700}
#sbg-clean-overlaps{width:100%;margin-top:12px;font-size:.8rem}
.sbg-projects{display:grid;gap:5px;max-height:450px;overflow:auto}
.sbg-projects a,.sbg-link{display:block;text-decoration:none;background:#fff;color:#15543f;border:1px solid #c3d9c6;border-radius:9px;padding:8px;font-size:.8rem}.sbg-projects small{display:block;color:#668272}
.sbg-page #sbg-selected-panel[hidden]{display:none}
.sbg-page dialog{border:1px solid #b8d3be;border-radius:16px;padding:22px;max-width:min(95vw,560px);max-height:90vh;overflow:auto;box-shadow:0 10px 60px #0006;background:#fbfff9;color:#1b493c}
.sbg-page dialog::backdrop{background:#091c1980}.sbg-page dialog .sbg-check{display:flex;flex-direction:row;align-items:flex-start;gap:8px}
/* The actual site container may be narrower than the browser window.
 * JS tests the REAL free space outside the dock. If it cannot fit a drawer,
 * keep tabs beside the board and let panels occupy a new row underneath.
 * Neither mode can resize or move the board. */
@media(min-width:901px){
 .sbg-layout.sbg-panels-below .sbg-dock{display:contents}
 .sbg-layout.sbg-panels-below .sbg-workspace{grid-column:1;grid-row:1}
 .sbg-layout.sbg-panels-below .sbg-dock-tabs{grid-column:2;grid-row:1}
 .sbg-layout.sbg-panels-below .sbg-dock-panels{position:static;grid-column:1/-1;grid-row:2;left:auto;right:auto;top:auto;max-width:100%;width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;padding:2px 0 8px;margin-top:4px}
 .sbg-layout.sbg-panels-below .sbg-dock-panel{flex:0 0 min(300px,78vw)}
}
@media(max-width:900px){.sbg-layout{display:flex;flex-direction:column;gap:6px}.sbg-workspace,.sbg-dock{width:100%}.sbg-dock{order:2;position:relative}.sbg-dock-tabs{flex-direction:row;gap:4px}.sbg-dock-tabs button{flex:1;min-width:0;min-height:48px}.sbg-dock-panels{position:static;max-width:100%;width:100%;overflow-x:auto;overflow-y:hidden;margin-top:6px}.sbg-dock-panel{flex:0 0 min(300px,80vw)}.sbg-viewport{height:clamp(300px,61vh,650px)}.sbg-layers{grid-template-columns:repeat(2,minmax(0,1fr))}.sbg-table-heading .sbg-muted{min-width:150px}}
@media(max-width:580px){.sbg-layout{display:flex;flex-direction:column;gap:6px}.sbg-workspace,.sbg-dock{width:100%}.sbg-dock{order:2;position:static}.sbg-dock-tabs{flex-direction:row;gap:4px}.sbg-dock-tabs button{flex:1;min-width:0;min-height:48px}.sbg-dock-panels{position:static;width:100%;max-width:100%;max-height:none;flex-direction:column;overflow:visible;padding:0;margin-top:6px;gap:6px}.sbg-dock-panel{position:static;width:100%;flex:0 0 auto;max-height:none;box-shadow:none}.sbg-drawer-section{max-height:48vh}.sbg-viewport{height:clamp(280px,52vh,500px)}.sbg-toolbar #sbg-status{margin-left:0;width:100%}.sbg-toolbar label{width:100%;max-width:none}.sbg-toolbar input{width:100%}.sbg-layer-foot #sbg-selected-readout{flex-basis:100%}.sbg-layers{gap:5px}}

@media(max-width:440px){.sbg-layer .sbg-layer-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal}.sbg-layer-select{overflow:hidden}}

/* Stage 1.4 opt-in shape/isometric/crop tools. Leave existing layout intact. */
.sbg-shape-section{border:1px solid #b5d4bf;border-radius:12px;padding:10px;margin-top:12px;background:#f2fbf5}
.sbg-shape-section>strong{display:block;font-size:.9rem;margin-bottom:9px}
.sbg-shape-buttons{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:8px 0}
.sbg-shape-buttons button{white-space:normal;min-height:40px;padding:7px;font-size:.78rem;line-height:1.25}
.sbg-shape-label{display:grid;gap:5px;font-size:.8rem;line-height:1.3}
.sbg-shape-label select{width:100%;min-height:42px}
.sbg-shape-note{font-size:.75rem;line-height:1.5;color:#426958;margin:8px 0}
@media (max-width:600px){.sbg-shape-buttons button{min-height:44px}}
/* Stage 1.4B: reveal all registered assets with accessible pagination. */
.sbg-page #sbg-more-assets{width:100%;display:block;margin:10px 0;min-height:42px;background:#ecf9ee;border:1px solid #97c6ac;font-weight:700}
.sbg-page #sbg-more-assets[hidden]{display:none!important}
#sbg-catalog-status{margin:6px 0 10px}


/* Stage 1.4C: compact SINGLE tabbed dock, not independent floating windows.
   Reserve the right column at initial layout so opening a tab does not shift,
   shrink, or cover the canvas. Canvas coordinates and zoom remain unchanged. */
@media (min-width:901px){
 .sbg-page .sbg-layout{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:10px;align-items:start}
 .sbg-page .sbg-dock{width:300px;min-width:0;position:relative;display:block}
 .sbg-page .sbg-dock-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px;align-items:stretch}
 .sbg-page .sbg-dock-tabs button{min-height:48px;padding:4px 1px;font-size:1.03rem;border-radius:9px 9px 4px 4px}
 .sbg-page .sbg-dock-panels{position:static;display:block;left:auto;right:auto;top:auto;width:100%;max-width:none;min-width:0;padding:0;margin-top:6px;overflow:visible;pointer-events:auto}
 .sbg-page .sbg-dock-panel{position:relative;display:flex;flex:1 1 auto;width:100%;max-height:min(72vh,700px);box-shadow:0 4px 15px #132f2620}
 .sbg-page .sbg-drawer-section{max-height:min(65vh,640px);overflow-y:auto;scrollbar-gutter:stable}
}
/* Below 900px the full-size workspace comes first, tabs and one panel below.
   The board width does not change when users open or switch a tab. */
@media (max-width:900px){
 .sbg-page .sbg-layout{display:flex;flex-direction:column;gap:8px}
 .sbg-page .sbg-workspace,.sbg-page .sbg-dock{width:100%;min-width:0}
 .sbg-page .sbg-dock{order:2;position:static;display:block}
 .sbg-page .sbg-dock-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}
 .sbg-page .sbg-dock-tabs button{min-width:0;min-height:48px;font-size:1rem;padding:4px 2px}
 .sbg-page .sbg-dock-panels{position:static;display:block;left:auto;right:auto;top:auto;width:100%;max-width:100%;max-height:none;padding:0;margin-top:6px;overflow:visible;pointer-events:auto}
 .sbg-page .sbg-dock-panel{position:relative;display:flex;width:100%;max-height:min(55vh,510px);flex:none;box-shadow:none}
 .sbg-page .sbg-drawer-section{max-height:min(48vh,460px);overflow-y:auto}
}
.sbg-page .sbg-dock-panel[hidden],.sbg-page .sbg-dock-panels:not(.has-open){display:none!important}
.sbg-page .sbg-dock-tabs button[aria-expanded=true]{background:#d4eee1;border-color:#18856c;border-bottom:3px solid #116c5e}
.sbg-page .sbg-dock-tabs button span{font-size:.65rem;white-space:nowrap}
