.composition-create{margin:1rem 0;padding:1rem}
.composition-create summary{font-size:1.1rem;font-weight:600;cursor:pointer}
.composition-create form{max-width:800px;margin-top:1rem}
.composition-create label{display:block;margin:.6rem 0 .25rem}
.composition-create input:not([type=checkbox]):not([type=color]),.composition-create textarea,.composition-create select{width:100%}
.composition-fields{display:flex;gap:1rem;align-items:center;flex-wrap:wrap}
.composition-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:1rem;margin-top:1rem}
.composition-list article{padding:1.2rem}
.composition-list h2{font-size:1.2rem;margin:0}
/* The viewport constraint is scoped to the editor; other application pages keep their normal scroll. */
html:has(.editor-page),body:has(.editor-page){height:100%;overflow:hidden}
.studio-shell:has(.editor-page){height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.main-content:has(>.editor-page){height:100%;min-height:0;max-width:none;padding:12px 16px;display:flex;flex-direction:column;overflow:hidden}
.editor-page{display:flex;flex-direction:column;flex:1;gap:8px;min-height:0;min-width:0}
.editor-header{display:flex;align-items:center;gap:10px;flex:none;min-width:0}
.editor-header h1{font-size:1.05rem;line-height:1.2;font-weight:600;white-space:nowrap;margin:0}
.editor-status{display:flex;align-items:center;gap:6px;min-width:0;font-size:.72rem;white-space:nowrap;overflow:hidden}
.editor-status-label{overflow:hidden;text-overflow:ellipsis}
.dirty-label{color:#f2ca84;font-weight:600}
.editor-header-actions{display:flex;align-items:center;gap:6px;margin-left:auto;flex:none}
.editor-icon-button,.editor-action{height:34px;padding:6px 10px;font-size:.82rem}
.editor-icon-button{width:34px;min-width:34px;padding:7px}
.editor-action{gap:6px}
.editor-header svg,.editor-zoom svg{flex:none}
.editor-more{position:relative}
.editor-more summary{list-style:none}
.editor-more summary::-webkit-details-marker{display:none}
.editor-more-content{position:absolute;right:0;top:calc(100% + 8px);z-index:30;width:min(340px,80vw);max-height:calc(100dvh - 75px);overflow:auto;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:12px;box-shadow:0 8px 25px #0005}
.editor-more-content p{margin:12px 0 0}
.editor-more-content button{width:100%;white-space:normal;font-size:.82rem}
.editor-secondary{display:grid;grid-template-columns:auto minmax(120px,240px) minmax(140px,320px) minmax(180px,1fr);align-items:center;gap:12px;flex:none;min-height:38px;min-width:0;overflow-x:auto;overflow-y:hidden}
.editor-dimensions{font-size:.75rem;white-space:nowrap;color:var(--muted);font-variant-numeric:tabular-nums}
.editor-inline-field{display:flex;align-items:center;gap:6px;min-width:0;white-space:nowrap;font-size:.72rem}
.editor-secondary .editor-inline-field input{min-width:0;width:100%;height:30px;font-size:.8rem;padding:4px 7px}
.editor-zoom{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-width:180px}
.editor-zoom label{font-size:.75rem;white-space:nowrap}
.editor-zoom input[type=range]{padding:0;border:0;background:transparent;accent-color:var(--accent);width:clamp(48px,7vw,100px);min-width:44px;height:24px}
.editor-zoom output{min-width:39px;text-align:right;white-space:nowrap;font-size:.75rem;font-variant-numeric:tabular-nums}
.editor-alerts{flex:none;min-height:0;max-height:25dvh;overflow:auto}
.editor-alerts .notice{margin:0 0 6px;padding:8px 12px;font-size:.82rem}
.editor-alerts .notice p{margin:0 0 6px}
.editor-alerts button{padding:5px 8px;font-size:.8rem}
.composition-editor{display:grid;grid-template-columns:clamp(150px,18vw,190px) minmax(0,1fr) clamp(190px,21vw,240px);gap:8px;flex:1;min-height:0;min-width:0;overflow:hidden}
.editor-panel{min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:10px}
.editor-panel h2{font-size:.85rem;margin:14px 0 6px}
.editor-panel fieldset{border:0;padding:0;margin:0 0 12px;min-width:0}
.editor-panel legend{font-size:.85rem;font-weight:600;margin-bottom:7px}
.editor-panel label{display:block;font-size:.75rem;margin:7px 0}
.editor-panel input:not([type=checkbox]):not([type=color]),.editor-panel select,.editor-panel textarea{display:block;width:100%;min-width:0;font-size:.8rem;padding:5px 7px;margin-top:3px}
.editor-panel input[type=color]{width:100%;height:30px;padding:2px;margin-top:3px}
.editor-panel textarea{resize:vertical}
.editor-panel button{font-size:.75rem;padding:6px 7px}
.editor-panel .actions{gap:5px;flex-wrap:wrap}
.editor-tools select{margin-bottom:6px}
.editor-layers{padding:0;margin:0 0 10px;list-style:none}
.editor-layers button{display:block;width:100%;text-align:left;margin:4px 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.editor-layers button.selected{border-color:var(--accent);background:#36452c;color:var(--text)}
.editor-layer-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
.editor-layer-actions button{white-space:normal}
.editor-workspace{min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;position:relative;background:#e7e9ee;border:1px solid #ced4de;border-radius:8px;padding:16px;display:flex;align-items:flex-start;justify-content:flex-start}
.editor-stage{flex:none;margin:auto;outline:none;background:repeating-conic-gradient(#d0d4da 0% 25%,#fff 0% 50%) 0/20px 20px;box-shadow:0 2px 10px #0002}
.editor-stage:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.editor-stage svg{overflow:hidden;user-select:none}
.editor-stage [data-element-id]{cursor:move}
.editor-stage [data-selection]{pointer-events:all}
.editor-context-heading{font-size:.75rem;font-weight:600;margin:0 0 8px;color:var(--muted)}
.editor-section{border-bottom:1px solid var(--border)}
.editor-section h2{margin:0}
.editor-panel .editor-section-toggle{display:flex;justify-content:space-between;align-items:center;gap:8px;width:100%;padding:9px 0;background:transparent;color:var(--text);border:0;border-radius:0;text-align:left;font-size:.85rem}
.editor-section-content{padding:0 0 10px}
.editor-section-content fieldset{margin:0}
.editor-property-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 8px}
.editor-panel .editor-check{display:flex;align-items:center;gap:6px}
.editor-selection-hint{margin:12px 0 0;font-size:.75rem}
.editor-reference{font-size:.8rem;overflow-wrap:anywhere;margin:6px 0}
@media(max-width:1100px){
    .composition-editor{grid-template-columns:150px minmax(0,1fr) 200px}
    .editor-secondary{gap:8px;grid-template-columns:auto minmax(100px,1fr) minmax(100px,1fr) auto}
    .editor-status-label{display:none}
}
@media(max-width:850px){
    .editor-action>span{display:none}
    .editor-action{width:34px;padding:7px}
    .main-content:has(>.editor-page){padding:8px}
    .composition-editor{grid-template-columns:130px minmax(0,1fr) 180px;gap:6px}
    .editor-inline-field>span{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden}
}
@media(max-width:700px){
    .studio-shell:has(.editor-page)>.sidebar{flex:none}
    .editor-secondary{grid-template-columns:auto minmax(90px,1fr) minmax(90px,1fr) auto}
    .composition-editor{grid-template-columns:120px minmax(0,1fr) 165px}
    .editor-header{gap:6px}
    .editor-header h1{font-size:.9rem}
}


/* Refreshing choices leaves the scene untouched and fits the tools column. */
.editor-refresh-images { width:100%; min-width:0; white-space:normal; margin-top:8px; }

.editor-tools { grid-column: 1; grid-row: 1; }
.editor-workspace { grid-column: 2; grid-row: 1; }
.editor-properties { grid-column: 3; grid-row: 1; }
.editor-stage[data-touch-edit=true] { touch-action: none; }
.editor-mobile-controls { display: none; }
@media (any-pointer: coarse) and (min-width: 901px) {
    .editor-mobile-controls { display: flex; grid-column: 1 / -1; grid-row: 2; }
    .editor-mobile-controls .panel-switch { display: none; }
    .composition-editor { grid-template-rows: minmax(0,1fr) auto; }
}
@media (max-width: 900px) {
    html:has(.editor-page), body:has(.editor-page) { height: auto; overflow: visible; }
    body .studio-shell:has(.editor-page) { height: auto; min-height: 100dvh; overflow: visible; display: flow-root; }
    html .studio-shell .main-content:has(>.editor-page),
    html[data-sidebar] .studio-shell .main-content:has(>.editor-page) {
        margin: 56px 0 0; width: 100%; height: auto; overflow: visible; padding: 10px;
    }
    html:not([data-editor-menu=open]) .studio-shell:has(.editor-page) > .sidebar { display: none; }
    .editor-page .editor-header { flex-wrap: wrap; }
    .editor-header .editor-header-actions { flex-wrap: wrap; gap: 4px; }
    .editor-header .editor-action > span { display: none; }
    .editor-header :is(.editor-icon-button,.editor-action), .editor-zoom .editor-icon-button {
        width: 42px; height: 42px; padding: 8px;
    }
    .editor-page .editor-secondary { grid-template-columns: minmax(0,1fr) minmax(0,1fr); overflow: visible; }
    .editor-secondary .editor-inline-field { grid-row: 1; display: grid; gap: 3px; }
    .editor-secondary .editor-inline-field > span { position: static; width: auto; height: auto; clip-path: none; }
    .editor-page .editor-zoom { min-width: 0; grid-column: 2; }
    .editor-page .editor-alerts { max-height: none; overflow: visible; }
    .editor-page .composition-editor { display: flex; flex-direction: column; overflow: visible; gap: 8px; }
    .composition-editor .editor-workspace {
        height: clamp(240px, 52dvh, 640px); flex: none; padding: 10px; overscroll-behavior: auto;
    }
    .editor-mobile-controls { display: flex; flex-wrap: wrap; gap: 6px; }
    .editor-mobile-controls button { flex: auto; min-height: 44px; white-space: normal; }
    .editor-mobile-controls :is([aria-expanded=true],[aria-pressed=true]) { border-color: var(--accent); background: var(--raised); }
    .composition-editor .editor-panel { display: none; overflow: visible; }
    .composition-editor[data-mobile-panel=tools] .editor-tools,
    .composition-editor[data-mobile-panel=properties] .editor-properties { display: block; }
    .editor-page .editor-panel button { min-height: 40px; }
    .editor-properties .image-adjust-panel.floating { position: static; width: 100%; max-height: none; overflow: visible; box-shadow: none; }
    .editor-properties .floating h3 { cursor: auto; touch-action: auto; }
}
