/* Creative workspace inspired by current Photoshop/Illustrator panel organization. */
#tab-pieces{--editor-bg:#202126;--editor-panel:#2b2d33;--editor-line:#444750;--editor-text:#e7e8ec;--editor-muted:#a4a8b3;--editor-active:#36587d;--editor-accent:#80b6f3}
html[data-theme=touch] #tab-pieces{--editor-bg:#1c1b23;--editor-panel:#292632;--editor-line:#494151;--editor-active:#4b3c68;--editor-accent:#bca2f5}
html[data-theme] #tab-pieces .pieces-heading{margin:0 0 12px;padding:0 2px}html[data-theme] #tab-pieces .pieces-heading h2{font-size:19px;font-weight:600;letter-spacing:-.02em}
html[data-theme] #tab-pieces .creative-editor{grid-template-columns:minmax(0,1fr) 330px;grid-template-areas:'monitor inspector' 'library library';gap:1px;background:var(--editor-line);border:1px solid var(--editor-line);border-radius:12px;overflow:visible;align-items:start}
html[data-theme] #tab-pieces .creative-editor>section{background:var(--editor-panel);border:0;border-radius:0;box-shadow:none}
html[data-theme] #tab-pieces .studio-monitor{grid-template-columns:60px minmax(0,1fr);grid-template-areas:'document document' 'menus menus' 'context context' 'tools canvas' 'actions actions' 'program program';gap:0;align-items:stretch;background:var(--editor-bg);min-width:0}
.creative-document-bar{grid-area:document;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 18px;background:#191a1e;color:var(--editor-text);border-bottom:1px solid var(--editor-line);min-height:52px;border-radius:11px 0 0 0}
.creative-document-bar strong{font-size:13px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.creative-document-bar>span{font-size:11px;color:var(--editor-muted);white-space:nowrap}
html[data-theme] #tab-pieces .composition-menu-bar{background:var(--editor-panel);border-radius:0;padding:3px 10px;border-color:var(--editor-line);gap:4px}
html[data-theme] #tab-pieces .composition-menu summary{padding:11px 12px;font-size:12px;min-height:44px;color:var(--editor-text);font-weight:400}
html[data-theme] #tab-pieces .composition-menu-content{background:var(--editor-panel);border-color:var(--editor-line);padding:6px;border-radius:8px}
html[data-theme] #tab-pieces .composition-menu-content .btn{background:transparent;color:var(--editor-text);border:0;box-shadow:none;min-height:44px;text-transform:none;font-weight:400;border-radius:5px}
html[data-theme] #tab-pieces .composition-menu-content .btn:hover{background:var(--editor-active)}
.creative-context{grid-area:context;display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:var(--editor-panel);border-bottom:1px solid var(--editor-line);padding:10px 14px;min-height:62px}
.creative-context>strong{font-size:11px;font-weight:500;min-width:65px;color:var(--editor-muted)}
html[data-theme] #tab-pieces .creative-context label{display:flex;align-items:center;gap:6px;margin:0;font-size:11px;color:var(--editor-muted)}
html[data-theme] #tab-pieces .creative-context input{width:68px;min-height:38px;height:38px;padding:7px;font-size:12px;border-radius:5px;background:var(--editor-bg);border-color:var(--editor-line);color:var(--editor-accent)}
html[data-theme] #tab-pieces #studio-composer-toolbar .composition-toolrail{gap:8px;padding:12px 7px;background:var(--editor-panel);border-right:1px solid var(--editor-line)}
html[data-theme] #tab-pieces .composition-toolrail .btn{width:44px;min-width:44px;height:48px;min-height:48px;display:flex;align-items:center;justify-content:center;background:transparent;color:#cbd0dc;box-shadow:none;border:1px solid transparent;border-radius:7px;padding:8px}
html[data-theme] #tab-pieces .composition-toolrail .btn:hover,html[data-theme] #tab-pieces .composition-toolrail .btn:focus-visible{background:var(--editor-active);color:#fff;border-color:var(--editor-accent)}
.composition-toolrail .composition-tool-label{display:none}
html[data-theme] #tab-pieces .composition-canvas-panel.card{padding:18px 24px;background:var(--editor-bg);border-radius:0;box-shadow:none}
html[data-theme] #tab-pieces .piece-preview-header{border:0;padding:0;margin:0 0 12px}.piece-preview-header strong{font-size:11px;font-weight:400;color:var(--editor-muted)}
html[data-theme] #tab-pieces .studio-monitor-settings{display:flex;align-items:center;gap:14px;padding:0;margin:0 0 18px;color:var(--editor-muted);font-size:11px}
html[data-theme] #tab-pieces .studio-monitor-settings label{font-size:11px;gap:7px;display:flex;align-items:center;margin:0}
html[data-theme] #tab-pieces .studio-monitor-settings select{min-height:40px;padding:8px;font-size:11px;background:#2b2d34;border-color:var(--editor-line);max-width:130px}
html[data-theme] #tab-pieces #piece-preview-wrap{border:0;box-shadow:0 4px 24px #0004;margin:0 0 16px;border-radius:0;overflow:auto;aspect-ratio:16/9;height:auto;min-height:0;max-height:65vh}
#composition-surface{position:relative;flex:none;overflow:hidden}#composition-surface #piece-preview-frame{top:0;left:0}
html[data-theme] #tab-pieces #piece-preview-wrap:not([data-zoom=fit]){height:clamp(260px,46vh,620px);aspect-ratio:auto}
html[data-theme] #tab-pieces .studio-inspector{padding:0;background:var(--editor-panel);border-radius:0 11px 0 0;overflow:visible}
html[data-theme] #tab-pieces .studio-inspector>.card{padding:16px;background:transparent;max-height:64vh;overflow:auto;border:0;border-radius:0;box-shadow:none}
html[data-theme] #tab-pieces .studio-inspector .card-title{font-size:12px;letter-spacing:0;font-weight:600;padding-bottom:12px;border-color:var(--editor-line)}
html[data-theme] #tab-pieces .studio-inspector #piece-name{font-size:12px;min-height:42px}
html[data-theme] #tab-pieces .composition-mode #piece-fields{display:none}
html[data-theme] #tab-pieces .studio-property-group summary{min-height:44px;padding:12px 0;font-size:12px;font-weight:500}
html[data-theme] #tab-pieces .studio-property-fields{gap:12px 10px;padding-top:6px}
html[data-theme] #tab-pieces .studio-property-fields label{color:var(--editor-muted);font-size:11px}
html[data-theme] #tab-pieces .studio-property-fields input:not([type=checkbox]),html[data-theme] #tab-pieces .studio-property-fields select{min-height:42px;padding:9px;font-size:12px;background:var(--editor-bg);border-color:var(--editor-line);border-radius:6px}
html[data-theme] #tab-pieces .studio-property-fields textarea{font-size:13px;min-height:88px;background:var(--editor-bg);border-color:var(--editor-line)}
html[data-theme] #tab-pieces .studio-property-group,html[data-theme] #tab-pieces .creative-document-settings{border-top:1px solid var(--editor-line)}
.creative-document-settings{margin-top:12px}.creative-document-settings>summary{font-size:12px;padding:12px 0;min-height:44px;cursor:pointer;color:var(--editor-muted)}
html[data-theme] #tab-pieces .studio-layer-panel{border:0;border-top:1px solid var(--editor-line);border-radius:0;padding:0;background:transparent}
html[data-theme] #tab-pieces .studio-panel-title{padding:14px 16px;font-size:12px;font-weight:600;color:var(--editor-text);background:#25272e;border-color:var(--editor-line)}
html[data-theme] #tab-pieces .composer-layers{max-height:320px;gap:0}
html[data-theme] #tab-pieces .composer-layer{display:grid;grid-template-columns:40px minmax(0,1fr) 40px;align-items:center;gap:0;background:#282a31;border:0;border-bottom:1px solid #333640;padding:4px 6px;min-height:58px}
html[data-theme] #tab-pieces .composer-layer.selected{background:var(--editor-active);border:0;border-bottom:1px solid #ffffff12}
html[data-theme] #tab-pieces .composer-layer .creative-layer-name{min-width:0;display:flex;align-items:center;gap:10px;text-align:left;font-size:12px;min-height:48px;height:auto;border:0;padding:4px!important;color:var(--editor-text);background:transparent;box-shadow:none;overflow-wrap:anywhere;line-height:1.4}
.creative-layer-thumb{display:inline-flex;align-items:center;justify-content:center;width:34px;height:30px;flex:0 0 34px;overflow:hidden;background:#15161a;border:1px solid #ffffff30;font-size:20px;color:#ddd}.creative-layer-thumb img{max-width:100%;max-height:100%;object-fit:contain}
html[data-theme] #tab-pieces .composer-layer .creative-layer-toggle{min-width:36px;min-height:48px;padding:8px!important;display:flex;align-items:center;justify-content:center;background:transparent;border:0;box-shadow:none;color:#d1d6e0;font-size:12px}
html[data-theme] #tab-pieces .creative-document-actions{grid-area:actions;display:flex;flex-wrap:wrap;gap:8px;padding:12px 16px;border-top:1px solid var(--editor-line);background:var(--editor-panel);margin:0}
html[data-theme] #tab-pieces .creative-document-actions .btn{min-height:44px;padding:10px 14px;font-size:12px;font-weight:500;flex:0 0 auto;box-shadow:none}
html[data-theme] #tab-pieces .creative-document-actions #piece-save-copy{order:1}html[data-theme] #tab-pieces .creative-document-actions #piece-save{order:2}html[data-theme] #tab-pieces .creative-document-actions #piece-add-cue{order:3}
html[data-theme] #tab-pieces .creative-document-actions #piece-take{order:4;margin-left:auto;min-height:44px;padding:10px 16px;font-size:12px}
html[data-theme] #tab-pieces .creative-document-actions #piece-out{order:5}
.creative-program-status{grid-area:program;display:flex;align-items:center;gap:10px;padding:10px 16px;background:var(--editor-panel)}.creative-program-status .hint{margin:0;font-size:11px}
.creative-library-drawer{grid-area:library;background:var(--editor-panel);min-width:0;border-radius:0 0 11px 11px}.creative-library-drawer>summary{cursor:pointer;min-height:48px;padding:16px;font-size:12px;color:var(--editor-muted)}
html[data-theme] #tab-pieces .creative-library-drawer .studio-library{border:0;box-shadow:none;padding:0;border-radius:0}
html[data-theme] #tab-pieces .creative-library-drawer .piece-library-list{grid-template-columns:repeat(3,minmax(0,1fr));max-height:350px}
html[data-theme] #tab-pieces .creative-library-drawer .piece-library-toolbar{flex-direction:row}
html[data-theme] #tab-pieces .creative-library-drawer .piece-library-footer{display:flex}
html[data-theme] #tab-pieces .creative-library-drawer .piece-template-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
@media(max-width:1050px){html[data-theme] #tab-pieces .creative-editor{grid-template-columns:minmax(0,1fr) 300px}.creative-context{gap:8px}html[data-theme] #tab-pieces .creative-context input{width:58px}html[data-theme] #tab-pieces .composition-canvas-panel.card{padding:16px}html[data-theme] #tab-pieces .studio-monitor-settings{flex-wrap:wrap}}
@media(max-width:800px){html[data-theme] #tab-pieces .creative-editor{grid-template-columns:minmax(0,1fr);grid-template-areas:'monitor' 'inspector' 'library'}html[data-theme] #tab-pieces .studio-inspector>.card{max-height:none}html[data-theme] #tab-pieces .creative-library-drawer .piece-library-list{grid-template-columns:repeat(2,minmax(0,1fr))}html[data-theme] #tab-pieces .creative-context input{min-height:44px}html[data-theme] #tab-pieces .studio-monitor-settings select{min-height:44px}.creative-context{gap:12px}.creative-program-status{flex-wrap:wrap}}
@media(max-width:500px){html[data-theme] #tab-pieces .creative-document-actions .btn{flex:1 1 130px}html[data-theme] #tab-pieces .creative-document-actions #piece-take{margin:0}html[data-theme] #tab-pieces .creative-library-drawer .piece-library-list{grid-template-columns:minmax(0,1fr)}html[data-theme] #tab-pieces .creative-library-drawer .piece-template-grid{grid-template-columns:minmax(0,1fr)}html[data-theme] #tab-pieces .composition-canvas-panel.card{padding:12px}}
html[data-theme] #tab-pieces .composition-toolrail .btn[aria-pressed=true]{background:var(--editor-active);color:#fff;border-color:#ffffff20}
html[data-theme] #tab-pieces .creative-context input,html[data-theme] #tab-pieces .studio-property-fields input:not([type=checkbox]),html[data-theme] #tab-pieces .studio-property-fields select{min-height:44px}
/* Stable viewport dimensions: fit never introduces a scrollbar feedback loop. */
html[data-theme] #tab-pieces #piece-preview-wrap[data-zoom=fit]{overflow:hidden;aspect-ratio:auto;max-height:none}
html[data-theme] #tab-pieces #piece-preview-wrap:not([data-zoom=fit]){scrollbar-gutter:stable}
/* The document owns its transparency background. The viewport is pasteboard,
   including the empty space exposed by a smaller zoom or a vertical canvas. */
html[data-theme] #tab-pieces .composition-canvas-panel.card{min-width:0}
html[data-theme] #tab-pieces #piece-preview-wrap,
html[data-theme] #tab-pieces #piece-preview-wrap[data-background]{background:var(--editor-bg);max-width:100%;min-width:0;box-shadow:none}
html[data-theme] #tab-pieces #composition-surface{margin-left:auto;margin-right:auto;box-shadow:0 0 0 1px #ffffff20;isolation:isolate}
html[data-theme] #tab-pieces #piece-preview-wrap[data-background=checker] #composition-surface{background:repeating-conic-gradient(#929292 0% 25%,#bebebe 0% 50%) 0/32px 32px}
html[data-theme] #tab-pieces #piece-preview-wrap[data-background=dark] #composition-surface{background:#151515}
html[data-theme] #tab-pieces #piece-preview-wrap[data-background=light] #composition-surface{background:#eee}
/* Expand this workspace to the browser width; JS measures the remaining height
   once controls are laid out, identically for fit and percentage zooms. */
html[data-theme] body.composition-workspace{max-width:none}
html[data-theme] #tab-pieces .composition-canvas-panel.card{padding:8px 12px}
html[data-theme] #tab-pieces .composition-canvas-panel .piece-preview-header{display:none}
html[data-theme] #tab-pieces #piece-preview-wrap,
html[data-theme] #tab-pieces #piece-preview-wrap[data-zoom=fit],
html[data-theme] #tab-pieces #piece-preview-wrap:not([data-zoom=fit]){aspect-ratio:auto;max-height:none}
html[data-theme] #tab-pieces #piece-preview-status:empty{display:none}
html[data-theme] #tab-pieces .studio-monitor-settings{margin:16px 0 8px;padding:10px 0 0;border-top:1px solid var(--editor-line);flex-wrap:wrap}
.composition-menu-content{margin-top:-1px}

html[data-theme] #tab-pieces .composition-menu-bar{flex-wrap:wrap;gap:4px}
html[data-theme] #tab-pieces .studio-monitor-settings .inline-check{display:flex;align-items:center;gap:8px;min-height:44px;cursor:pointer}
html[data-theme] #tab-pieces .studio-monitor-settings input[type=checkbox]{width:20px;height:20px;accent-color:var(--editor-active)}
html[data-theme] #tab-pieces .composer-layer.selected{background:var(--editor-active);border-color:#76baff80}

html[data-theme] #tab-pieces .creative-document-actions #piece-to-preview{order:4;margin-left:auto;min-height:44px;padding:10px 16px}html[data-theme] #tab-pieces .creative-document-actions #piece-to-preview:not([hidden])+#piece-take{order:5;margin-left:0}html[data-theme] #tab-pieces .creative-document-actions #piece-out{order:6}
@media(max-width:500px){html[data-theme] #tab-pieces .creative-document-actions #piece-to-preview{margin-left:0}}
/* Reusable server media: compact browsing, generous insertion targets. */
.composition-media{width:min(900px,92vw);max-height:85vh;overflow:auto;background:var(--panel-bg,#20232a);color:var(--text,#e6e9ef);border:1px solid #4b5260;border-radius:16px;padding:20px;box-shadow:0 24px 80px #0009}
.composition-media::backdrop{background:#0009}
.composition-media header,.composition-media footer,.composition-media-filters{display:flex;align-items:center;gap:12px}
.composition-media header{justify-content:space-between}.composition-media h2{margin:0;font-size:20px}.composition-media-filters{margin-top:18px}.composition-media-filters input{flex:1;min-width:0}
.composition-media button,.composition-media input,.composition-media select{min-height:44px;background:#303640;color:#edf0f6;border:1px solid #566070;border-radius:8px;padding:8px 12px;font:inherit}
.composition-media button{cursor:pointer}.composition-media button:hover{background:#414c5f}.composition-media button:focus-visible{outline:2px solid #69a8ff;outline-offset:2px}.composition-media button:disabled{opacity:.4;cursor:default}
.composition-media p{color:#bac3d2;font-size:14px}.composition-media-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}.composition-media .composition-media-item{display:flex;flex-direction:column;gap:8px;text-align:left;min-width:0;padding:10px}.composition-media-item img{width:100%;height:100px;object-fit:contain;background:repeating-conic-gradient(#3c414b 0% 25%,#292e37 0% 50%) 0/16px 16px;border-radius:5px}.composition-media-item span{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.composition-media-item small{color:#bbc5d4}.composition-media footer{justify-content:flex-end;margin-top:18px}
@media(max-width:600px){.composition-media-filters{flex-wrap:wrap}.composition-media-filters input{flex-basis:100%}.composition-media{padding:14px}}
html[data-theme] #tab-pieces .composer-tools .composition-action-icon{width:44px;min-width:44px;height:44px;min-height:44px;padding:10px!important;display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px}
html[data-theme] #tab-pieces .composer-tools .composition-action-delete{color:#ff8b92;border-color:#b74853;background:#672c37}
html[data-theme] #tab-pieces .composer-tools .composition-action-delete:hover:not(:disabled){color:#fff;background:#ce3546;border-color:#ed5968}
html[data-theme] #tab-pieces .composition-action-icon:focus-visible{outline:2px solid #78b5ff;outline-offset:2px}
html[data-theme] #tab-pieces .composition-document-tools{min-width:280px;padding:14px;gap:12px;display:flex;flex-direction:column}
html[data-theme] #tab-pieces .composition-document-tools label{display:flex;flex-direction:column;gap:6px;color:#c7cfdc;font-size:12px}
html[data-theme] #tab-pieces .composition-document-tools .inline-check{flex-direction:row;align-items:center;min-height:44px}
html[data-theme] #tab-pieces .composition-document-tools select,html[data-theme] #tab-pieces .composition-document-tools input[type=number]{min-height:44px;width:100%}
html[data-theme] #tab-pieces .composition-document-tools small{color:#aab5c6;max-width:280px;white-space:normal;line-height:1.5}
#studio-composer-actions> .composer-tools>label{display:flex;align-items:center;gap:8px;flex-basis:100%;font-size:12px;color:#c7cfdc}#studio-composer-actions select{min-height:44px;flex:1;min-width:0}
.composition-guides-dialog{width:min(600px,92vw);max-height:80vh;overflow:auto;background:#242832;color:#e6ebf4;border:1px solid #556176;border-radius:14px;padding:20px}.composition-guides-dialog::backdrop{background:#0009}.composition-guides-dialog h2{font-size:20px;margin:0 0 20px}.composition-guide-list{display:flex;flex-direction:column;gap:10px}.composition-guide-list>div,.composition-guides-dialog footer{display:flex;gap:10px}.composition-guides-dialog footer{margin-top:20px;flex-wrap:wrap}.composition-guides-dialog input,.composition-guides-dialog select,.composition-guides-dialog button{min-height:44px;min-width:0;padding:8px 12px;background:#333b49;color:#edf0f5;border:1px solid #5b677b;border-radius:7px;font:inherit}.composition-guide-list input{width:100px;flex:1}.composition-guides-dialog button{cursor:pointer}.composition-guides-dialog :focus-visible{outline:2px solid #78b5ff;outline-offset:2px}
